From 0c8d1ba4a8f1a5106b15c2a61c70cd27d966d546 Mon Sep 17 00:00:00 2001 From: opsu <50782355+opsuu@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:16:42 +0200 Subject: [PATCH] Buffer overflow fix (#1707) --- src/helpers/MiscFunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 10d59316..ab3c826e 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -209,7 +209,7 @@ std::string removeBeginEndSpacesTabs(std::string str) { } int countAfter = 0; - while (str.length() != 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) { + while ((int)str.length() - countAfter - 1 >= 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) { countAfter++; } @@ -562,4 +562,4 @@ std::string replaceInString(std::string subject, const std::string& search, cons pos += replace.length(); } return subject; -} \ No newline at end of file +}