summaryrefslogtreecommitdiff
path: root/external/harfbuzz
diff options
context:
space:
mode:
Diffstat (limited to 'external/harfbuzz')
-rw-r--r--external/harfbuzz/UnpackedTarball_harfbuzz.mk1
-rw-r--r--external/harfbuzz/ubsan.patch32
2 files changed, 33 insertions, 0 deletions
diff --git a/external/harfbuzz/UnpackedTarball_harfbuzz.mk b/external/harfbuzz/UnpackedTarball_harfbuzz.mk
index 178627a32574..9a2967220e25 100644
--- a/external/harfbuzz/UnpackedTarball_harfbuzz.mk
+++ b/external/harfbuzz/UnpackedTarball_harfbuzz.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,harfbuzz,0))
$(eval $(call gb_UnpackedTarball_add_patches,harfbuzz, \
external/harfbuzz/clang-cl.patch \
+ external/harfbuzz/ubsan.patch \
))
ifneq ($(ENABLE_RUNTIME_OPTIMIZATIONS),TRUE)
diff --git a/external/harfbuzz/ubsan.patch b/external/harfbuzz/ubsan.patch
new file mode 100644
index 000000000000..b855d5f2140d
--- /dev/null
+++ b/external/harfbuzz/ubsan.patch
@@ -0,0 +1,32 @@
+--- src/hb-ot-font.cc
++++ src/hb-ot-font.cc
+@@ -138,7 +138,7 @@
+ return this->default_advance;
+ }
+
+- return this->table->longMetric[MIN (glyph, (uint32_t) this->num_advances - 1)].advance
++ return static_cast<OT::LongMetric const *>(this->table->longMetric)[MIN (glyph, (uint32_t) this->num_advances - 1)].advance
+ + this->var->get_advance_var (glyph, font->coords, font->num_coords); // TODO Optimize?!
+ }
+ };
+@@ -458,8 +458,9 @@
+ }
+
+ static void
+-_hb_ot_font_destroy (hb_ot_font_t *ot_font)
++_hb_ot_font_destroy (void *ot_font_)
+ {
++ hb_ot_font_t *ot_font = static_cast<hb_ot_font_t *>(ot_font_);
+ ot_font->cmap.fini ();
+ ot_font->h_metrics.fini ();
+ ot_font->v_metrics.fini ();
+--- src/hb-private.hh
++++ src/hb-private.hh
+@@ -461,6 +461,7 @@
+ template <typename T>
+ inline const Type *bsearch (T *key) const
+ {
++ if (len == 0) return NULL;
+ return (const Type *) ::bsearch (key, array, len, sizeof (Type), (hb_compare_func_t) Type::cmp);
+ }
+