fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / external / icu / icu4c-scriptrun.patch
blobe307811acaadbf86ab87404b69f85a9c31b02de0
1 --- misc/icu/source/extra/scrptrun/scrptrun.cpp
2 +++ misc/build/icu/source/extra/scrptrun/scrptrun.cpp
3 @@ -150,7 +150,11 @@
4 // characters above it on the stack will be poped.
5 if (pairIndex >= 0) {
6 if ((pairIndex & 1) == 0) {
7 - parenStack[++parenSP].pairIndex = pairIndex;
8 + ++parenSP;
9 + int32_t nVecSize = parenStack.size();
10 + if (parenSP == nVecSize)
11 + parenStack.resize(nVecSize + 128);
12 + parenStack[parenSP].pairIndex = pairIndex;
13 parenStack[parenSP].scriptCode = scriptCode;
14 } else if (parenSP >= 0) {
15 int32_t pi = pairIndex & ~1;
16 @@ -184,7 +188,14 @@
17 // pop it from the stack
18 if (pairIndex >= 0 && (pairIndex & 1) != 0 && parenSP >= 0) {
19 parenSP -= 1;
20 - startSP -= 1;
21 + /* decrement startSP only if it is >= 0,
22 + decrementing it unnecessarily will lead to memory corruption
23 + while processing the above while block.
24 + e.g. startSP = -4 , parenSP = -1
25 + */
26 + if (startSP >= 0) {
27 + startSP -= 1;
28 + }
30 } else {
31 // if the run broke on a surrogate pair,
32 --- misc/icu/source/extra/scrptrun/scrptrun.h
33 +++ misc/build/icu/source/extra/scrptrun/scrptrun.h
34 @@ -17,6 +17,7 @@
35 #include "unicode/utypes.h"
36 #include "unicode/uobject.h"
37 #include "unicode/uscript.h"
38 +#include <vector>
40 struct ScriptRecord
42 @@ -79,7 +80,7 @@
43 int32_t scriptEnd;
44 UScriptCode scriptCode;
46 - ParenStackEntry parenStack[128];
47 + std::vector<ParenStackEntry> parenStack;
48 int32_t parenSP;
50 static int8_t highBit(int32_t value);
51 @@ -133,6 +134,7 @@
52 scriptEnd = charStart;
53 scriptCode = USCRIPT_INVALID_CODE;
54 parenSP = -1;
55 + parenStack.resize(128);
58 inline void ScriptRun::reset(int32_t start, int32_t length)