From fb13510681952abaf475b5188dd3333503501369 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 2 Jul 2017 15:45:02 -0700 Subject: 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 --- src/corelib/io/qfilesystemengine_unix.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index e195afdae9..4ffa6b8972 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -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; -- cgit v1.2.3