--- src/fcdir.c
+++ src/fcdir.c
@@ -265,7 +265,7 @@
/*
* Sort files to make things prettier
*/
- qsort(files->strs, files->num, sizeof(FcChar8 *), cmpstringp);
+ if (files->num != 0) qsort(files->strs, files->num, sizeof(FcChar8 *), cmpstringp);
* Scan file files to build font patterns
--- src/fcserialize.c
+++ src/fcserialize.c
@@ -163,7 +163,7 @@
size_t old_used = serialize->buckets_used;
size_t old_count = serialize->buckets_count;
FcSerializeBucket *old_buckets = serialize->buckets;
- FcSerializeBucket *old_buckets_end = old_buckets + old_count;
+ FcSerializeBucket *old_buckets_end = old_count == 0 ? old_buckets : old_buckets + old_count;
FcSerializeBucket *new_buckets = malloc (new_count * sizeof (*old_buckets));
if (!new_buckets)