diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2009-08-21 12:52:12 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-08-21 13:10:33 (GMT) |
commit | 2e27e9b38766b4c0a2c9ec20539cf808de01f2dd (patch) | |
tree | 8b5b51738d7b4f7eb20be9c859f089e7f227ac7f | |
parent | 4209fa5809f5a0a8de2a346c56a0640cc15193ee (diff) | |
download | Qt-2e27e9b38766b4c0a2c9ec20539cf808de01f2dd.zip Qt-2e27e9b38766b4c0a2c9ec20539cf808de01f2dd.tar.gz Qt-2e27e9b38766b4c0a2c9ec20539cf808de01f2dd.tar.bz2 |
improve error reporting for map/unmap of files and resources
Merge-request: 833
Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 6 |
3 files changed, 8 insertions, 12 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 592f792..96ea96e 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -966,14 +966,14 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla { Q_Q(QFSFileEngine); Q_UNUSED(flags); - if (offset < 0) { - q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); - return 0; - } if (openMode == QIODevice::NotOpen) { q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); return 0; } + if (offset < 0) { + q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); + return 0; + } int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index c7510f2..e524e8e 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1798,11 +1798,11 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, Q_Q(QFSFileEngine); Q_UNUSED(flags); if (openMode == QFile::NotOpen) { - q->setError(QFile::PermissionsError, qt_error_string()); + q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); return 0; } if (offset == 0 && size == 0) { - q->setError(QFile::UnspecifiedError, qt_error_string()); + q->setError(QFile::UnspecifiedError, qt_error_string(ERROR_INVALID_PARAMETER)); return 0; } @@ -1884,7 +1884,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) { Q_Q(QFSFileEngine); if (!maps.contains(ptr)) { - q->setError(QFile::PermissionsError, qt_error_string()); + q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); return false; } uchar *start = ptr - maps[ptr].first; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 212f153..242af61 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1488,11 +1488,7 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory { Q_Q(QResourceFileEngine); Q_UNUSED(flags); - if (!resource.isValid() - || offset < 0 - || size < 0 - || offset + size > resource.size() - || (size == 0)) { + if (offset < 0 || size <= 0 || !resource.isValid() || offset + size > resource.size()) { q->setError(QFile::UnspecifiedError, QString()); return 0; } |