summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/PPToken.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-06-17 16:40:04 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-06-18 07:52:02 +0000
commit8eac3fba8093750f4dfe6b8ab01f7f998fcadd26 (patch)
tree12e173ea817c54e5ab6182c7cfce200cc4672dd5 /src/libs/cplusplus/PPToken.cpp
parent1b8c68f61727d6d04b1375b969b5f96688e67fde (diff)
downloadqt-creator-8eac3fba8093750f4dfe6b8ab01f7f998fcadd26.tar.gz
CPlusPlus: Fix lexer crash
At some point in the preprocessing stage, some tokens get "squeezed", so their associated string no longer refers to the document content, but only to their own symbol. However, there is at least one context that operated under the assumption that the token's offset still pointed into the "global" string. As the token's offset is zero after parsing, this lead to the same piece of code being preprocessed in an infinite loop. Fixes: QTCREATORBUG-19525 Change-Id: I231ba51811cfa0b5c6dfe7f75fe0384472252c6f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/cplusplus/PPToken.cpp')
-rw-r--r--src/libs/cplusplus/PPToken.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libs/cplusplus/PPToken.cpp b/src/libs/cplusplus/PPToken.cpp
index 2f352fa109..ff3996aba9 100644
--- a/src/libs/cplusplus/PPToken.cpp
+++ b/src/libs/cplusplus/PPToken.cpp
@@ -54,6 +54,7 @@ void PPToken::squeezeSource()
if (hasSource()) {
m_src = m_src.mid(byteOffset, f.bytes);
m_src.squeeze();
+ m_originalOffset = byteOffset;
byteOffset = 0;
utf16charOffset = 0;
}