Skip to content

Commit 4fbc23c

Browse files
committed
Merge pull request #152 from sparkprime/fix_strip_ws
Fix #151
2 parents 6b2fe56 + 9c0863c commit 4fbc23c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/lexer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static const std::vector<std::string> EMPTY;
2828
/** Strip whitespace from both ends of a string, but only up to margin on the left hand side. */
2929
static std::string strip_ws(const std::string &s, unsigned margin)
3030
{
31+
if (s.size() == 0) return s; // Avoid underflow below.
3132
size_t i = 0;
3233
while (i < s.length() && (s[i] == ' ' || s[i] == '\t' || s[i] == '\r') && i < margin)
3334
i++;

0 commit comments

Comments
 (0)