forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -366,6 +366,14 @@ void tst_SimpleLexer::literals_data()
|
||||
<< T_RAW_STRING_LITERAL
|
||||
;
|
||||
QTest::newRow("raw-string-literals") << source << expectedTokenKindList;
|
||||
|
||||
source = "R\"\\" ;
|
||||
expectedTokenKindList = TokenKindList() << T_ERROR;
|
||||
QTest::newRow("invalid-raw-string-literals1") << source << expectedTokenKindList;
|
||||
|
||||
source = "R\")" ;
|
||||
expectedTokenKindList = TokenKindList() << T_ERROR;
|
||||
QTest::newRow("invalid-raw-string-literals2") << source << expectedTokenKindList;
|
||||
}
|
||||
|
||||
void tst_SimpleLexer::preprocessor()
|
||||
|
||||
Reference in New Issue
Block a user