From 4b65e052bf2b3566bd50e6ba812e153e2a85e2b2 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Thu, 19 Jun 2014 11:48:18 +1000 Subject: Bug [#1614]. Don't crash on incomplete macro definition "#define x(". --- lexers/LexCPP.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lexers') diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index b7ff1859b..5485bf228 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -1220,7 +1220,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, size_t startValue = endArgs+1; while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue])) startValue++; - std::string value = restOfLine.substr(startValue); + std::string value; + if (startValue < restOfLine.length()) + value = restOfLine.substr(startValue); preprocessorDefinitions[key] = SymbolValue(value, args); ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args)); definitionsChanged = true; -- cgit v1.2.3