diff options
author | Peter Kümmel <syntheticpp@gmx.net> | 2013-02-22 08:58:41 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-01 08:55:51 (GMT) |
commit | 2fd65bf3f5015fc9ff830b4a8709fe65d9644f17 (patch) | |
tree | 06c06774ef7da46271998de239fea66b14ff8627 /src/corelib/io | |
parent | c4c5e8c595ce7c51094a7eff330b01e3ffbf05c0 (diff) | |
download | Qt-2fd65bf3f5015fc9ff830b4a8709fe65d9644f17.zip Qt-2fd65bf3f5015fc9ff830b4a8709fe65d9644f17.tar.gz Qt-2fd65bf3f5015fc9ff830b4a8709fe65d9644f17.tar.bz2 |
Fix CreateFileMapping() error handling
CreateFileMapping() returns NULL in case of an error.
The patch corrects the wrong testing on INVALID_HANDLE_VALUE, and sets
NULL for invalid handles.
Change-Id: Iaab4945ed88ee92bbf9a0871e95a5820dd1a56ed
(cherry-picked from qtbase/1a8f67938c4146614fec3788c7868dc1a314cc84)
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index c2d70b6..929a369 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -132,7 +132,7 @@ void QFSFileEnginePrivate::init() #ifdef Q_OS_WIN fileAttrib = INVALID_FILE_ATTRIBUTES; fileHandle = INVALID_HANDLE_VALUE; - mapHandle = INVALID_HANDLE_VALUE; + mapHandle = NULL; #ifndef Q_OS_WINCE cachedFd = -1; #endif diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 8ee18e9..7a80b9a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -910,7 +910,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, return 0; } - if (mapHandle == INVALID_HANDLE_VALUE) { + if (mapHandle == NULL) { // get handle to the file HANDLE handle = fileHandle; @@ -943,7 +943,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, // first create the file mapping handle DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); - if (mapHandle == INVALID_HANDLE_VALUE) { + if (mapHandle == NULL) { q->setError(QFile::PermissionsError, qt_error_string()); #ifdef Q_USE_DEPRECATED_MAP_API ::CloseHandle(handle); @@ -986,6 +986,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, } ::CloseHandle(mapHandle); + mapHandle = NULL; return 0; } @@ -1005,7 +1006,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) maps.remove(ptr); if (maps.isEmpty()) { ::CloseHandle(mapHandle); - mapHandle = INVALID_HANDLE_VALUE; + mapHandle = NULL; } return true; |