diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-08-18 17:50:44 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2021-08-23 12:32:25 +0200 |
commit | fd9a94594fc42347e1b08f83ae62e7d42aee1e6b (patch) | |
tree | d695dd045d7b8ff2d14df2e25282e8024eb9bf98 /src/corelib/io | |
parent | 77bdce84965662a67162d1272245b168c96875db (diff) |
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>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdir.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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); |