forked from qt-creator/qt-creator
FileName: Add a soft assertion against invalid parent in parentDir
In case isRoot() returns false, but cleanPath fails to find the parent directory, return an empty string. For example: QDir::cleanPath("D:/..") returns "D:/.." on Windows. I'm not aware of any concrete case when this can happen, but let's be cautious. Change-Id: I0f4af5f5c11bb768d99d90290a4a1a6a1bda7c27 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
030901a743
commit
b00017e0ad
@@ -631,6 +631,7 @@ FileName FileName::parentDir() const
|
|||||||
|
|
||||||
const QString path = basePath + QLatin1String("/..");
|
const QString path = basePath + QLatin1String("/..");
|
||||||
const QString parent = QDir::cleanPath(path);
|
const QString parent = QDir::cleanPath(path);
|
||||||
|
QTC_ASSERT(parent != path, return FileName());
|
||||||
|
|
||||||
return FileName::fromString(parent);
|
return FileName::fromString(parent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user