diff options
author | ShadowNinja <shadowninja@minetest.net> | 2022-01-29 22:50:43 -0500 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2022-04-08 14:55:21 +0100 |
commit | f5e54cd39845aeeff50cdbebf625abf3c4a5b92d (patch) | |
tree | 11251621dcae9414bb644366709494d8dcced8d7 /src/util | |
parent | c9317a16c5877d5c7bb2c1e684fa56fc73a53413 (diff) | |
download | minetest-f5e54cd39845aeeff50cdbebf625abf3c4a5b92d.tar.gz minetest-f5e54cd39845aeeff50cdbebf625abf3c4a5b92d.tar.bz2 minetest-f5e54cd39845aeeff50cdbebf625abf3c4a5b92d.zip |
Fix OOB read in trim("")
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/string.h | 4 |
1 files changed, 2 insertions, 2 deletions
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; |