summaryrefslogtreecommitdiffstats
path: root/external/fontconfig/ubsan.patch
blob: 91586b09348098761311838da3ef49fc0f825a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- 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)