aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-04 11:43:36 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-04 13:51:55 +0000
commitb74d620bf051aacfba15f962424738b77a36f392 (patch)
tree7a57942140a302693d73af8bcfd30025920f0cde
parent913dc6473ddd93dbc6d3d260a4a4445696ba3b09 (diff)
CppEditor: Fix crash with adjacent raw string literals
Our lexer is not good at handling newlines embedded in raw string literals; basically, it sees every continuation line as a new string. So if such a continuation is followed directly by a new raw string literal, we have to take care to tell them apart properly. In particular, it can happen that an end delimiter occurs before an opening delimiter. Fixes: QTCREATORBUG-24577 Change-Id: I631d0617d85e91f49a25d309d53778da0170eb3b Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/cppeditor/cpphighlighter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp
index 3b7827d211..51aa17eed4 100644
--- a/src/plugins/cppeditor/cpphighlighter.cpp
+++ b/src/plugins/cppeditor/cpphighlighter.cpp
@@ -396,6 +396,8 @@ bool CppHighlighter::highlightRawStringLiteral(const QStringView &_text, const T
if (text.at(tk.utf16charsEnd() - 1) != '"')
return false;
const int endDelimiterOffset = tk.utf16charsEnd() - 1 - delimiter.length();
+ if (endDelimiterOffset <= delimiterOffset)
+ return false;
if (text.mid(endDelimiterOffset, delimiter.length()) != delimiter)
return false;
if (text.at(endDelimiterOffset - 1) != ')')