1 --- misc/icu/source/extra/scrptrun/scrptrun.cpp
2 +++ misc/build/icu/source/extra/scrptrun/scrptrun.cpp
4 // characters above it on the stack will be poped.
6 if ((pairIndex & 1) == 0) {
7 - parenStack[++parenSP].pairIndex = pairIndex;
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;
17 // pop it from the stack
18 if (pairIndex >= 0 && (pairIndex & 1) != 0 && parenSP >= 0) {
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
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
35 #include "unicode/utypes.h"
36 #include "unicode/uobject.h"
37 #include "unicode/uscript.h"
44 UScriptCode scriptCode;
46 - ParenStackEntry parenStack[128];
47 + std::vector<ParenStackEntry> parenStack;
50 static int8_t highBit(int32_t value);
52 scriptEnd = charStart;
53 scriptCode = USCRIPT_INVALID_CODE;
55 + parenStack.resize(128);
58 inline void ScriptRun::reset(int32_t start, int32_t length)