aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2017-09-19 14:36:21 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2017-09-20 07:38:04 +0000
commit76006a1353f1282a940bf80a523b93ead7beae93 (patch)
tree1dd61134c864ec691800f4fc338a45ccdeace348 /src/libs/3rdparty
parent0bf27af0a718887248229b9693de16f150a38bf3 (diff)
C++: Fix crash with invalid raw string literal
While parsing a document Bind::asStringLiteral() Token::spell() was called for a raw string literal token with a Token::literal nullptr. This is due scanRawStringLiteral() not properly aborting for invalid/incomplete code and that the code paths handling multi-line-raw-strings were not limited to the highlighting case. Address both cases. Task-number: QTCREATORBUG-18941 Change-Id: I489d288ccbd7b59be396dada846613ff555436cf Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/libs/3rdparty')
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp
index e62c9412a4..079ae0ca6e 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.cpp
+++ b/src/libs/3rdparty/cplusplus/Lexer.cpp
@@ -211,7 +211,7 @@ void Lexer::scan_helper(Token *tok)
_state = 0;
scanCppComment(originalKind);
return;
- } else if (isRawStringLiteral(s._tokenKind)) {
+ } else if (!control() && isRawStringLiteral(s._tokenKind)) {
tok->f.kind = s._tokenKind;
if (scanUntilRawStringLiteralEndSimple())
_state = 0;
@@ -755,13 +755,17 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
yyinp();
} else if (_yychar == ')') {
yyinp();
- if (delimLength == -1)
- break;
+ if (delimLength == -1) {
+ tok->f.kind = T_ERROR;
+ return;
+ }
closingDelimCandidate = _currentChar;
} else {
if (delimLength == -1) {
- if (_yychar == '\\' || std::isspace(_yychar))
- break;
+ if (_yychar == '\\' || std::isspace(_yychar)) {
+ tok->f.kind = T_ERROR;
+ return;
+ }
yyinp();
} else {
if (!closingDelimCandidate) {
@@ -804,7 +808,7 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
else
tok->f.kind = T_RAW_STRING_LITERAL;
- if (!closed)
+ if (!control() && !closed)
s._tokenKind = tok->f.kind;
}