[apps/shared] ToolBoxHelpers: don't overflow buffer

If the commandLength is > than the buffer size, we have to escape at
some point to avoid overflowing the buffer.
This commit is contained in:
Émilie Feral
2020-07-28 16:30:04 +02:00
committed by LeaNumworks
parent 3e6e1729a2
commit b4a3dd10e1

View File

@@ -41,7 +41,7 @@ void TextToInsertForCommandText(const char * command, int commandLength, char *
UTF8Decoder decoder(command);
CodePoint codePoint = decoder.nextCodePoint();
while (codePoint != UCodePointNull && (commandLength < 0 || (decoder.stringPosition() - command <= commandLength))) {
while (codePoint != UCodePointNull && index < bufferSize - 1 && (commandLength < 0 || (decoder.stringPosition() - command <= commandLength))) {
if (codePoint == ')') {
numberOfOpenParentheses--;
} else if (codePoint == ']') {