mirror of
https://github.com/minetest/minetest.git
synced 2024-12-11 08:53:15 +01:00
Fix OOB read in trim("")
This commit is contained in:
parent
cc91477308
commit
d945d0129c
@ -295,11 +295,11 @@ inline std::string lowercase(const std::string &str)
|
|||||||
inline std::string trim(const std::string &str)
|
inline std::string trim(const std::string &str)
|
||||||
{
|
{
|
||||||
size_t front = 0;
|
size_t front = 0;
|
||||||
|
size_t back = str.size();
|
||||||
|
|
||||||
while (std::isspace(str[front]))
|
while (front < back && std::isspace(str[front]))
|
||||||
++front;
|
++front;
|
||||||
|
|
||||||
size_t back = str.size();
|
|
||||||
while (back > front && std::isspace(str[back - 1]))
|
while (back > front && std::isspace(str[back - 1]))
|
||||||
--back;
|
--back;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user