summaryrefslogtreecommitdiffstats
path: root/external/fontconfig/ubsan.patch
diff options
context:
space:
mode:
Diffstat (limited to 'external/fontconfig/ubsan.patch')
-rw-r--r--external/fontconfig/ubsan.patch22
1 files changed, 22 insertions, 0 deletions
diff --git a/external/fontconfig/ubsan.patch b/external/fontconfig/ubsan.patch
new file mode 100644
index 0000000000..91586b0934
--- /dev/null
+++ b/external/fontconfig/ubsan.patch
@@ -0,0 +1,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)