summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-07-02 15:45:02 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-05 14:35:20 +0000
commitfb13510681952abaf475b5188dd3333503501369 (patch)
treece63a3107364eaeeb37d4b68643dec791aef55aa /src
parentf065d0f128a09b3faec2a4d3ee6b0952b486e471 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp10
1 files changed, 1 insertions, 9 deletions
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;