Skip to content

Commit

Permalink
Fix OOB read in trim("")
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja authored and rubenwardy committed Apr 8, 2022
1 parent c9317a1 commit f5e54cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f5e54cd

Please sign in to comment.