QFileSystemEngine::fillMetaData: fix apparent use of dangling pointer
It's not dangling only because of QFileSystemMetaData's construction: the nativeFilePath() function returns a member variable. Since QByteArray COWs, the pointer that we stored would not be freed. But this was dangerous, since any change to the "entry" variable could cause it to invalidate the member variable and the pointer to become dangling. This line is only as old as this entire file is. Change-Id: I8d96dea9955d4c749b99fffd14cda4d8e2cc5e5b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f065d0f128
commit
fb13510681
@ -449,15 +449,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
|
||||
|
||||
data.entryFlags &= ~what;
|
||||
|
||||
const char * nativeFilePath;
|
||||
int nativeFilePathLength;
|
||||
{
|
||||
const QByteArray &path = entry.nativeFilePath();
|
||||
nativeFilePath = path.constData();
|
||||
nativeFilePathLength = path.size();
|
||||
Q_UNUSED(nativeFilePathLength);
|
||||
}
|
||||
|
||||
const QByteArray nativeFilePath = entry.nativeFilePath();
|
||||
bool entryExists = true; // innocent until proven otherwise
|
||||
|
||||
QT_STATBUF statBuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user