From 9c0863c14d53dd9d25c92a085242384fc514c2a3 Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Fri, 1 Apr 2016 02:29:51 -0400 Subject: [PATCH] Fix #151 --- core/lexer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lexer.cpp b/core/lexer.cpp index ec837919e..343df558f 100644 --- a/core/lexer.cpp +++ b/core/lexer.cpp @@ -28,6 +28,7 @@ static const std::vector EMPTY; /** Strip whitespace from both ends of a string, but only up to margin on the left hand side. */ static std::string strip_ws(const std::string &s, unsigned margin) { + if (s.size() == 0) return s; // Avoid underflow below. size_t i = 0; while (i < s.length() && (s[i] == ' ' || s[i] == '\t' || s[i] == '\r') && i < margin) i++;