From e691370e4faee21fe92922e3caf0b48958ffa962 Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 31 Jan 2019 20:17:59 +0100 Subject: [PATCH] [EU-FOSSA] Fix stack overflow in extractSymbol function --- PowerEditor/src/Notepad_plus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ce96a166..0f859b7c 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3952,9 +3952,10 @@ void Notepad_plus::showFunctionComp() static generic_string extractSymbol(TCHAR firstChar, TCHAR secondChar, const TCHAR *str2extract) { bool found = false; - TCHAR extracted[128] = TEXT(""); + const size_t extractedLen = 128; + TCHAR extracted[extractedLen] = {'\0'}; - for (size_t i = 0, j = 0, len = lstrlen(str2extract) ; i < len ; ++i) + for (size_t i = 0, j = 0, len = lstrlen(str2extract) ; i < len && j < extractedLen - 1; ++i) { if (found) { @@ -3964,7 +3965,6 @@ static generic_string extractSymbol(TCHAR firstChar, TCHAR secondChar, const TCH return generic_string(extracted); } extracted[j++] = str2extract[i]; - } else {