QDir: add assert for nullptr ok parameter in qt_cleanPath

Found by CodeChecker.
The function returns early in case of empty path, but the bool
parameter is never updated in this case. It's not a problem
with the current codebase though.
As it's a static local function, the reasonable solution is just
to add an assert, so that we do not get hit in case of refactoring.

Task-number: QTBUG-95727
Pick-to: 6.2
Change-Id: Idc00356c61b5db8b2204a574612c1ea8e65f4a69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Ivan Solovev 2021-08-18 17:50:44 +02:00
parent 77bdce8496
commit fd9a94594f
1 changed files with 3 additions and 1 deletions

View File

@ -2281,8 +2281,10 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
static QString qt_cleanPath(const QString &path, bool *ok)
{
if (path.isEmpty())
if (path.isEmpty()) {
Q_ASSERT(!ok); // The only caller passing ok knows its path is non-empty
return path;
}
QString name = QDir::fromNativeSeparators(path);
QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization, ok);