diff options
author | Oliver Wolff <[email protected]> | 2025-06-17 14:37:47 +0200 |
---|---|---|
committer | Oliver Wolff <[email protected]> | 2025-06-19 11:24:05 +0200 |
commit | ada927d19a9d0e2c6bc23b3a08b9bf05a985d685 (patch) | |
tree | 821a1bd8566ede9f221753e36f0bf19e2282d71a | |
parent | 8d60a45974cde33f1bd2f82a339dc6c13b855c5b (diff) |
windeployqt: Fix access of invalid iterators crash
We must not use a range based loop here as the container might be
changed inside the loop which will invalidate the iterators which in
turn might lead to a crash.
While at it the QFileInfo used to obtain the binary's path was moved out
of the loop as a small cleanup.
Fixes: QTBUG-137763
Pick-to: 6.10 6.9 6.8
Change-Id: I86fb8b683fb98a897d0059ef1dc869e26b2c213f
Reviewed-by: Joerg Bornemann <[email protected]>
-rw-r--r-- | src/tools/windeployqt/main.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp index 496fa512621..7d3808d301a 100644 --- a/src/tools/windeployqt/main.cpp +++ b/src/tools/windeployqt/main.cpp @@ -1490,10 +1490,13 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString> } } + const QFileInfo fi(options.binaries.first()); + const QString canonicalBinPath = fi.canonicalPath(); // Also check Qt dependencies of "local non Qt dependencies" (dlls located in the same folder) - for (const QString &nonQtLib : dependentNonQtLibs) { - const QFileInfo fi(options.binaries.first()); - const QString path = fi.canonicalPath() + u'/' + nonQtLib; + // Index based loop as container might be changed which invalidates iterators + for (qsizetype i = 0; i < dependentNonQtLibs.size(); ++i) { + const QString nonQtLib = dependentNonQtLibs.at(i); + const QString path = canonicalBinPath + u'/' + nonQtLib; if (!QFileInfo::exists(path)) continue; |