summaryrefslogtreecommitdiff
path: root/external/harfbuzz/ubsan.patch
blob: fde85cf81761db9bc98b220fafb29001586cf088 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- src/hb-ot-font.cc
+++ src/hb-ot-font.cc
@@ -125,7 +125,7 @@
     if (glyph >= this->num_advances)
       glyph = this->num_advances - 1;
 
-    return this->table->longMetric[glyph].advance;
+    return static_cast<OT::LongMetric const *>(this->table->longMetric)[glyph].advance;
   }
 };
 
@@ -394,8 +394,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-ot-map-private.hh
+++ src/hb-ot-map-private.hh
@@ -52,8 +52,11 @@
     unsigned int needs_fallback : 1;
     unsigned int auto_zwj : 1;
 
-    static int cmp (const feature_map_t *a, const feature_map_t *b)
-    { return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; }
+    static int cmp (void const * a_, void const * b_) {
+      feature_map_t const * a = static_cast<feature_map_t const *>(a_);
+      feature_map_t const * b = static_cast<feature_map_t const *>(b_);
+      return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0;
+    }
   };
 
   struct lookup_map_t {
--- src/hb-ot-tag.cc
+++ src/hb-ot-tag.cc
@@ -778,9 +778,11 @@
 };
 
 static int
-lang_compare_first_component (const char *a,
-			      const char *b)
+lang_compare_first_component (void const * a_,
+			      void const * b_)
 {
+  char const * a = static_cast<char const *>(a_);
+  char const * b = static_cast<char const *>(b_);
   unsigned int da, db;
   const char *p;
 
--- src/hb-private.hh
+++ src/hb-private.hh
@@ -466,6 +466,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);
   }