summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-09-13 13:15:46 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-09-13 13:25:55 +0000
commit4b852b4e04574e9d6780ff041163af2427c2a350 (patch)
tree4d64949db80fd9c67c2aa5eec2b35432674d67f0 /src/libs
parent5b454c95fc2fc3f107280b59e5bf26d9038a65c2 (diff)
downloadqt-creator-4b852b4e04574e9d6780ff041163af2427c2a350.tar.gz
CPlusPlus: Do not handle extremely long function-like macros
Qt Creator almost hangs and consumes a lot of memory if that happens. Just ignore such cases in preprocessor. Task-number: QTCREATORBUG-18995 Change-Id: Ib81cc18738696b02f98e5064d06c719a44ebdaa3 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 3ef5e2c38e..5ee8298a72 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -76,6 +76,7 @@ using namespace Utils;
namespace {
enum {
+ MAX_FUNCTION_LIKE_ARGUMENTS_COUNT = 100,
MAX_TOKEN_EXPANSION_COUNT = 5000,
MAX_TOKEN_BUFFER_DEPTH = 16000 // for when macros are using some kind of right-folding, this is the list of "delayed" buffers waiting to be expanded after the current one.
};
@@ -1058,6 +1059,9 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
argRefs);
}
+ if (allArgTks.size() > MAX_FUNCTION_LIKE_ARGUMENTS_COUNT)
+ return false;
+
if (!handleFunctionLikeMacro(macro, body, allArgTks, baseLine)) {
if (m_client && !idTk.expanded())
m_client->stopExpandingMacro(idTk.byteOffset, *macro);