diff options
author | João Abecasis <joao@abecasis.name> | 2009-07-27 15:12:50 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-08-24 17:25:48 (GMT) |
commit | 6d87a01f2d3108bbee5b9995f20edfc26a01cd57 (patch) | |
tree | 10a33d8b07bac5f79f5eaed3686a130f96b94dd8 /src/corelib/io | |
parent | 8c7aab40e2860071de2e66a2074328472e53f45f (diff) | |
download | Qt-6d87a01f2d3108bbee5b9995f20edfc26a01cd57.zip Qt-6d87a01f2d3108bbee5b9995f20edfc26a01cd57.tar.gz Qt-6d87a01f2d3108bbee5b9995f20edfc26a01cd57.tar.bz2 |
Always check the file handle before attempting to map the file
Reviewed-by: Maurice Kalinowski
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 2d4fe0e..2fc9670 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1927,8 +1927,9 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, #ifndef Q_OS_WINCE if (handle == INVALID_HANDLE_VALUE && fh) handle = (HANDLE)_get_osfhandle(QT_FILENO(fh)); -#else - #ifdef Q_USE_DEPRECATED_MAP_API +#endif + +#ifdef Q_USE_DEPRECATED_MAP_API if (fileMapHandle == INVALID_HANDLE_VALUE) { nativeClose(); fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), @@ -1940,11 +1941,13 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, NULL); } handle = fileMapHandle; - #endif - if (handle == INVALID_HANDLE_VALUE && fh) - return 0; #endif + if (handle == INVALID_HANDLE_VALUE) { + q->setError(QFile::UnspecifiedError, QLatin1String("No handle on file")); + return 0; + } + // first create the file mapping handle DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); |