summaryrefslogtreecommitdiff
path: root/external/graphite/ubsan.patch
blob: 86039de4e1c868b07268d6cf9aa9ca0da38c44c1 (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
--- src/TtfUtil.cpp
+++ src/TtfUtil.cpp
@@ -1247,7 +1247,7 @@
 void * GlyfLookup(const void * pGlyf, size_t nGlyfOffset, size_t nTableLen)
 {
     const uint8 * pByte = reinterpret_cast<const uint8 *>(pGlyf);
-        if (nGlyfOffset + pByte < pByte || nGlyfOffset + sizeof(Sfnt::Glyph) >= nTableLen)
+        if (nGlyfOffset > nTableLen || sizeof(Sfnt::Glyph) >= nTableLen - nGlyfOffset)
             return NULL;
     return const_cast<uint8 *>(pByte + nGlyfOffset);
 }
--- src/gr_face.cpp
+++ src/gr_face.cpp
@@ -87,7 +87,7 @@
 
     Face *res = new Face(appFaceHandle, *ops);
     if (res && load_face(*res, faceOptions))
-        return static_cast<gr_face *>(res);
+        return reinterpret_cast<gr_face *>(res);
 
     delete res;
     return 0;
@@ -195,7 +195,7 @@
 
 void gr_face_destroy(gr_face *face)
 {
-    delete face;
+    delete static_cast<Face *>(face);
 }
 
 
--- src/gr_font.cpp
+++ src/gr_font.cpp
@@ -50,7 +50,7 @@
     if (face == 0)  return 0;
 
     Font * const res = new Font(ppm, *face, appFontHandle, font_ops);
-    return static_cast<gr_font*>(res);
+    return reinterpret_cast<gr_font*>(res);
 }
 
 gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, gr_advance_fn getAdvance, const gr_face * face/*needed for scaling*/)
@@ -61,7 +61,7 @@
 
 void gr_font_destroy(gr_font *font)
 {
-    delete font;
+    delete static_cast<Font *>(font);
 }
 
 
--- src/inc/Code.h
+++ src/inc/Code.h
@@ -162,7 +162,7 @@
 {
     if (_code && !_own)
     {
-        _code += dist / sizeof(instr);
+        _code += dist / int(sizeof(instr));
         _data += dist;
     }
 }