Fix OOB read in trim("")

This commit is contained in:
ShadowNinja 2022-01-29 22:50:43 -05:00 committed by rubenwardy
parent c9317a16c5
commit f5e54cd398

@ -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;