diff options
author | BLooperZ | 2019-12-31 22:12:45 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2020-01-01 00:31:21 +0100 |
commit | c10ed91c3e4c96ca26fda15137f2d65655ecc742 (patch) | |
tree | a49c3a442559ce9e480fe0399ecba05c6ec32c27 /engines/scumm | |
parent | 7f8b584aa3e77e1d886b6ea3b1058305b03fe765 (diff) | |
download | scummvm-rg350-c10ed91c3e4c96ca26fda15137f2d65655ecc742.tar.gz scummvm-rg350-c10ed91c3e4c96ca26fda15137f2d65655ecc742.tar.bz2 scummvm-rg350-c10ed91c3e4c96ca26fda15137f2d65655ecc742.zip |
SCUMM: avoid allocating large buffers on stack
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/string.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp index 633a67792c..c2a07fa54b 100644 --- a/engines/scumm/string.cpp +++ b/engines/scumm/string.cpp @@ -478,6 +478,13 @@ void ScummEngine::fakeBidiString(char *ltext, bool ignoreVerb) { int start = 0; char *text = ltext + ll; char *current = text; + + int bufferSize = 384; + char * const buff = (char *)calloc(sizeof(char), bufferSize); + assert(buff); + char * const stack = (char *)calloc(sizeof(char), bufferSize); + assert(stack); + while (1) { if (*current == 13 || *current == 0 || *current == -1 || *current == -2) { @@ -490,10 +497,8 @@ void ScummEngine::fakeBidiString(char *ltext, bool ignoreVerb) { continue; } - char buff[384]; - memset(buff, 0, sizeof(buff)); - char stack[384]; - memset(stack, 0, sizeof(stack)); + memset(buff, 0, bufferSize); + memset(stack, 0, bufferSize); int sthead = 0; char last = '\0'; @@ -546,6 +551,9 @@ void ScummEngine::fakeBidiString(char *ltext, bool ignoreVerb) { ltext[start + ipos + ll] = '\x80'; ltext[start + ipos + ll + 1] = '\0'; } + + free(buff); + free(stack); } void ScummEngine::CHARSET_1() { |