summaryrefslogtreecommitdiff
path: root/external/icu/icu-ubsan.patch.0
blob: c6baaede4b4e4e1c6238bdfb2e881ce390298987 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--- source/common/rbbidata.h
+++ source/common/rbbidata.h
@@ -113,7 +113,7 @@
                                     /*     StatusTable of the set of matching             */
                                     /*     tags (rule status values)                      */
     int16_t          fReserved;
-    uint16_t         fNextState[2]; /*  Next State, indexed by char category.             */
+    uint16_t         fNextState[1]; /*  Next State, indexed by char category.             */
                                     /*  This array does not have two elements             */
                                     /*    Array Size is actually fData->fHeader->fCatCount         */
                                     /*    CAUTION:  see RBBITableBuilder::getTableSize()  */
@@ -126,7 +126,7 @@
     uint32_t         fRowLen;       /*  Length of a state table row, in bytes.            */
     uint32_t         fFlags;        /*  Option Flags for this state table                 */
     uint32_t         fReserved;     /*  reserved                                          */
-    char             fTableData[4]; /*  First RBBIStateTableRow begins here.              */
+    char             fTableData[1]; /*  First RBBIStateTableRow begins here.              */
                                     /*    (making it char[] simplifies ugly address       */
                                     /*     arithmetic for indexing variable length rows.) */
 };
--- source/common/rbbitblb.cpp
+++ source/common/rbbitblb.cpp
@@ -1067,15 +1067,15 @@
         return 0;
     }
 
-    size    = sizeof(RBBIStateTable) - 4;    // The header, with no rows to the table.
+    size    = offsetof(RBBIStateTable, fTableData);    // The header, with no rows to the table.
 
     numRows = fDStates->size();
     numCols = fRB->fSetBuilder->getNumCharCategories();
 
-    //  Note  The declaration of RBBIStateTableRow is for a table of two columns.
-    //        Therefore we subtract two from numCols when determining
+    //  Note  The declaration of RBBIStateTableRow is for a table of one columns.
+    //        Therefore we subtract one from numCols when determining
     //        how much storage to add to a row for the total columns.
-    rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-2);
+    rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-1);
     size   += numRows * rowSize;
     return size;
 }
@@ -1105,7 +1105,7 @@
     }
 
     table->fRowLen    = sizeof(RBBIStateTableRow) +
-                            sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 2);
+                            sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 1);
     table->fNumStates = fDStates->size();
     table->fFlags     = 0;
     if (fRB->fLookAheadHardBreak) {
--- source/common/ucharstriebuilder.cpp
+++ source/common/ucharstriebuilder.cpp
@@ -285,7 +285,7 @@
 
 UCharsTrieBuilder::UCTLinearMatchNode::UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode)
         : LinearMatchNode(len, nextNode), s(units) {
-    hash=hash*37+ustr_hashUCharsN(units, len);
+    hash=hash*37U+ustr_hashUCharsN(units, len);
 }
 
 UBool
--- source/common/ucmndata.h
+++ source/common/ucmndata.h
@@ -50,7 +50,7 @@
 
 typedef struct {
     uint32_t count;
-    UDataOffsetTOCEntry entry[2];    /* Actual size of array is from count. */
+    UDataOffsetTOCEntry entry[1];    /* Actual size of array is from count. */
 } UDataOffsetTOC;
 
 /**
--- source/common/unicode/stringtriebuilder.h
+++ source/common/unicode/stringtriebuilder.h
@@ -269,7 +269,7 @@
         void setValue(int32_t v) {
             hasValue=TRUE;
             value=v;
-            hash=hash*37+v;
+            hash=hash*37U+v;
         }
     protected:
         UBool hasValue;
@@ -296,7 +296,7 @@
     class LinearMatchNode : public ValueNode {
     public:
         LinearMatchNode(int32_t len, Node *nextNode)
-                : ValueNode((0x333333*37+len)*37+hashCode(nextNode)),
+                : ValueNode((0x333333U*37+len)*37+hashCode(nextNode)),
                   length(len), next(nextNode) {}
         virtual UBool operator==(const Node &other) const;
         virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
@@ -330,7 +330,7 @@
             equal[length]=NULL;
             values[length]=value;
             ++length;
-            hash=(hash*37+c)*37+value;
+            hash=(hash*37U+c)*37+value;
         }
         // Adds a unit which leads to another match node.
         void add(int32_t c, Node *node) {
@@ -338,7 +338,7 @@
             equal[length]=node;
             values[length]=0;
             ++length;
-            hash=(hash*37+c)*37+hashCode(node);
+            hash=(hash*37U+c)*37+hashCode(node);
         }
     protected:
         Node *equal[kMaxBranchLinearSubNodeLength];  // NULL means "has final value".
@@ -353,7 +353,7 @@
     class SplitBranchNode : public BranchNode {
     public:
         SplitBranchNode(UChar middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)
-                : BranchNode(((0x555555*37+middleUnit)*37+
+                : BranchNode(((0x555555U*37+middleUnit)*37+
                               hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),
                   unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}
         virtual UBool operator==(const Node &other) const;
@@ -370,7 +370,7 @@
     class BranchHeadNode : public ValueNode {
     public:
         BranchHeadNode(int32_t len, Node *subNode)
-                : ValueNode((0x666666*37+len)*37+hashCode(subNode)),
+                : ValueNode((0x666666U*37+len)*37+hashCode(subNode)),
                   length(len), next(subNode) {}
         virtual UBool operator==(const Node &other) const;
         virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
--- source/common/uresbund.cpp
+++ source/common/uresbund.cpp
@@ -53,7 +53,7 @@
     UHashTok namekey, pathkey;
     namekey.pointer = b->fName;
     pathkey.pointer = b->fPath;
-    return uhash_hashChars(namekey)+37*uhash_hashChars(pathkey);
+    return uhash_hashChars(namekey)+37U*uhash_hashChars(pathkey);
 }
 
 /* INTERNAL: compares two entries */