From a6caac2b61de0f1edfc2db1ec695218e4c8be7ea Mon Sep 17 00:00:00 2001 From: Mae Dartmann Date: Thu, 12 May 2022 12:08:18 +0200 Subject: [PATCH] Fix string underflow in removeBeginEndSpacesTabs() Signed-off-by: Mae Dartmann Changes to be committed: modified: src/helpers/MiscFunctions.cpp --- src/helpers/MiscFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index bf8724c6..61ae0c49 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -69,7 +69,7 @@ std::string removeBeginEndSpacesTabs(std::string str) { str = str.substr(1); } - while (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t') { + while (str.length() != 0 && (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t')) { str = str.substr(0, str.length() - 1); }