diff options
author | Richard Weickelt <richard@weickelt.de> | 2020-07-08 23:48:32 +0200 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2020-07-13 22:25:42 +0000 |
commit | 91ca67815af4512004d11a582753d4e6980e2004 (patch) | |
tree | e51f6d2fa4ba253db4b8f716e60e625add95f190 /share/qbs | |
parent | 09401f5eab3f5c8955e85baf3c98f79fbc03d8b1 (diff) |
Fix wrong array iteration
It is not recommended to use 'for in' loops to iterate over arrays
because additional properties in Array.prototype would be iterated over
as well. For unknown reasons this is not the case when using QtScript,
but it would be a problem when running on QJSEngine.
Change-Id: I4404c03a6277dae471a9beb162b539edb9ace426
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'share/qbs')
-rw-r--r-- | share/qbs/imports/qbs/ModUtils/utils.js | 2 | ||||
-rw-r--r-- | share/qbs/modules/java/utils.js | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js index 502fa1e45..507e68088 100644 --- a/share/qbs/imports/qbs/ModUtils/utils.js +++ b/share/qbs/imports/qbs/ModUtils/utils.js @@ -408,7 +408,7 @@ var PropertyValidator = (function () { errorMessage += "The following properties have invalid values:\n"; lines = []; for (i in invalidProperties) { - for (j in invalidProperties[i]) { + for (j = 0; j < invalidProperties[i].length; ++j) { lines.push(this.moduleName + "." + i + ": " + invalidProperties[i][j]); } } diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js index 0e11b7d3e..520511192 100644 --- a/share/qbs/modules/java/utils.js +++ b/share/qbs/modules/java/utils.js @@ -74,10 +74,9 @@ function jdkRootRegistryKey(wow64) { function findJdkPath(hostOS, arch, environmentPaths, searchPaths) { var i; - for (var key in environmentPaths) { - if (environmentPaths[key]) { - return environmentPaths[key]; - } + for (i = 0; i < environmentPaths.length; ++i) { + if (environmentPaths[i]) + return environmentPaths[i]; } if (hostOS.contains("windows")) { @@ -347,7 +346,7 @@ function manifestContents(filePath) { if (contents) { var dict = {}; var lines = contents.split(/\r?\n/g).filter(function (line) { return line.length > 0; }); - for (var i in lines) { + for (var i = 0; i < lines.length; ++i) { var kv = lines[i].split(":"); if (kv.length !== 2) throw new Error("Syntax error in manifest file '" |