summaryrefslogtreecommitdiff
path: root/external/hunspell/ubsan.patch.0
blob: b52802d209f4b72c1ec8d307b4c95620efeaffc0 (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
--- src/hunspell/hashmgr.cxx
+++ src/hunspell/hashmgr.cxx
@@ -479,7 +479,7 @@
 
 int HashMgr::hash(const char * word) const
 {
-    long  hv = 0;
+    unsigned long  hv = 0;
     for (int i=0; i < 4  &&  *word != 0; i++)
         hv = (hv << 8) | (*word++);
     while (*word != 0) {
--- src/hunspell/csutil.cxx
+++ src/hunspell/csutil.cxx
@@ -147,7 +147,7 @@
         case 0xd0: {    // 2-byte UTF-8 codes
             if ((*(u8+1) & 0xc0) == 0x80) {
                 u2->h = (*u8 & 0x1f) >> 2;
-                u2->l = (*u8 << 6) + (*(u8+1) & 0x3f);
+                u2->l = (*reinterpret_cast<unsigned char const *>(u8) << 6) + (*(u8+1) & 0x3f);
                 u8++;
             } else {
                 HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (signed char *)src), src);
@@ -158,10 +158,10 @@
         }
         case 0xe0: {    // 3-byte UTF-8 codes
             if ((*(u8+1) & 0xc0) == 0x80) {
-                u2->h = ((*u8 & 0x0f) << 4) + ((*(u8+1) & 0x3f) >> 2);
+                u2->h = ((*reinterpret_cast<unsigned char const *>(u8) & 0x0f) << 4) + ((*(u8+1) & 0x3f) >> 2);
                 u8++;
                 if ((*(u8+1) & 0xc0) == 0x80) {
-                    u2->l = (*u8 << 6) + (*(u8+1) & 0x3f);
+                    u2->l = (*reinterpret_cast<unsigned char const *>(u8) << 6) + (*(u8+1) & 0x3f);
                     u8++;
                 } else {
                     HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (signed char *)src), src);