diff options
author | ShadowNinja <shadowninja@minetest.net> | 2022-01-29 22:50:43 -0500 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-14 18:33:42 +0200 |
commit | d945d0129c812084bc6db878c6ead76b1483fa3b (patch) | |
tree | 9099775279111cce45cc6ca415a68bdbc5135c3e /src | |
parent | cc9147730836c7b3d8047fad00662ca13b0b93ea (diff) | |
download | minetest-d945d0129c812084bc6db878c6ead76b1483fa3b.tar.gz minetest-d945d0129c812084bc6db878c6ead76b1483fa3b.tar.bz2 minetest-d945d0129c812084bc6db878c6ead76b1483fa3b.zip |
Fix OOB read in trim("")
Diffstat (limited to 'src')
-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 8a9e83f22..d73540ceb 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; |