QFileSystemEngine: fix potential formatting error
It's not immediately clear that trashedName doesn't contain %1 or %2, in which case the subsequent .arg() would replace that instead of the intended %2. Fix by using QString::asprintf(), which doesn't perform multiple interpolation passes. Pick-to: 6.3 6.2 5.15 Change-Id: Ib6c24bfea01db4cdc80f7547c8269cce3f815158 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
parent
f3c340c276
commit
bbae5c891b
@ -1374,10 +1374,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
|
||||
int counter = 0;
|
||||
QFile infoFile;
|
||||
auto makeUniqueTrashedName = [trashedName, &counter]() -> QString {
|
||||
++counter;
|
||||
return QString(QLatin1String("/%1-%2"))
|
||||
.arg(trashedName)
|
||||
.arg(counter, 4, 10, QLatin1Char('0'));
|
||||
return QString::asprintf("/%ls-%04d", qUtf16Printable(trashedName), ++counter);
|
||||
};
|
||||
do {
|
||||
while (QFile::exists(trashDir.filePath(filesDir) + uniqueTrashedName))
|
||||
|
Loading…
Reference in New Issue
Block a user