aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-08-28 10:27:59 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-08-28 08:50:23 +0000
commit25ab750e3ade13633e56f0313b19b7e9fd4ff59e (patch)
treeeb338b0b1fb7f7c5a9b1fbc5f29735183e4e819e
parentcfebe5a9da85078c4dcf1500a69c212517e2c35d (diff)
qmake: Prevent injection of empty values via environment variables
The qmake $() operator retrieves environment values at make time. In Qt Creator, we still use these values for feeding the code model, presumably because the qmake and make step share a common environment. However, we must take care that unset environment values do not lead to empty strings in qmake lists, as that can have unwanted side effects, especially when these lists get turned into command line arguments that are passed to build tools. A concrete example: A project file contained the following assignment: QMAKE_CXXFLAGS += $(SOME_VAR) SOME_VAR was not set in the environment, so an additional empty argument appeared on the command line when the code model called the MSVC compiler to retrieve some information required for parsing the code. The call failed, the code model had to fall back to default values, and the user got parsing errors. Fixes: QTCREATORBUG-21729 Change-Id: I224369a2fb9c0dd78406253edba03bd44556be44 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/shared/proparser/profileevaluator.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp
index 3b816f01cd..f6b2d3c5f3 100644
--- a/src/shared/proparser/profileevaluator.cpp
+++ b/src/shared/proparser/profileevaluator.cpp
@@ -71,8 +71,11 @@ QStringList ProFileEvaluator::values(const QString &variableName) const
const ProStringList &values = d->values(ProKey(variableName));
QStringList ret;
ret.reserve(values.size());
- foreach (const ProString &str, values)
- ret << d->m_option->expandEnvVars(str.toQString());
+ for (const ProString &str : values) {
+ const QString expanded = d->m_option->expandEnvVars(str.toQString());
+ if (!expanded.isEmpty() || str.isEmpty())
+ ret << expanded;
+ }
return ret;
}