From f5e54cd39845aeeff50cdbebf625abf3c4a5b92d Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sat, 29 Jan 2022 22:50:43 -0500 Subject: Fix OOB read in trim("") --- src/util/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/string.h b/src/util/string.h index d8ec633ee..aa4329f2f 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -295,11 +295,11 @@ inline std::string lowercase(const std::string &str) inline std::string trim(const std::string &str) { size_t front = 0; + size_t back = str.size(); - while (std::isspace(str[front])) + while (front < back && std::isspace(str[front])) ++front; - size_t back = str.size(); while (back > front && std::isspace(str[back - 1])) --back; -- cgit v1.2.3