summaryrefslogtreecommitdiff
path: root/external/harfbuzz/ubsan.patch
blob: b855d5f2140d3dc8f9c08485a3292dcd8b73c779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
   }