aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorRichard Weickelt <richard@weickelt.de>2020-08-13 13:37:11 +0200
committerRichard Weickelt <richard@weickelt.de>2020-08-14 07:58:34 +0000
commit0820c2d3ca6ac2e01c1d68945beeba45f4212658 (patch)
tree55c3318e64077f5737020cd3c67c4ef5ec82fa5c /share
parentf456797d9b3fa5826a31631714a1c605de006371 (diff)
Avoid wrong-typed temporary assignment to probe property
The code assigns a temporary string to the cflags and libs properties which are both declared as stringList. Later, it reads these properties, expects string values and converts them into arrays. While this seems to work with the current QtScript engine, it won't with the QML-based evaluation engine. That is because any read access to a item property will return exactly the declared type or undefined. In this particular case, we would assign the temporary string to a stringList property which the engine would automatically convert into a stringList (array) when reading and thus, calling split() would result in an error. Change-Id: I53e0c51ee042f787e0d444cdc6cfe4b8820e46ac Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs9
1 files changed, 5 insertions, 4 deletions
diff --git a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
index b295c7441..2ed772227 100644
--- a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
@@ -60,6 +60,7 @@ Probe {
if (!packageNames || packageNames.length === 0)
throw 'PkgConfigProbe.packageNames must be specified.';
var p = new Process();
+ var stdout;
try {
var libDirsToSet = libDirs;
if (sysroot) {
@@ -86,14 +87,14 @@ Probe {
}
var args = packageNames;
if (p.exec(executable, args.concat([ '--cflags' ])) === 0) {
- cflags = p.readStdOut().trim();
- cflags = cflags ? cflags.split(/\s/) : [];
+ stdout = p.readStdOut().trim();
+ cflags = stdout ? stdout.split(/\s/): [];
var libsArgs = args.concat("--libs");
if (forStaticBuild)
libsArgs.push("--static");
if (p.exec(executable, libsArgs) === 0) {
- libs = p.readStdOut().trim();
- libs = libs ? libs.split(/\s/) : [];
+ stdout = p.readStdOut().trim();
+ libs = stdout ? stdout.split(/\s/): [];
if (p.exec(executable, [packageNames[0]].concat([ '--modversion' ])) === 0) {
modversion = p.readStdOut().trim();
found = true;