From fd9a94594fc42347e1b08f83ae62e7d42aee1e6b Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 18 Aug 2021 17:50:44 +0200 Subject: [PATCH] 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 --- src/corelib/io/qdir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index fd2f0e3067..19afc0572a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -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);