From b74d620bf051aacfba15f962424738b77a36f392 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 4 Sep 2020 11:43:36 +0200 Subject: 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 --- src/plugins/cppeditor/cpphighlighter.cpp | 2 ++ 1 file changed, 2 insertions(+) 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) != ')') -- cgit v1.2.3