diff options
Diffstat (limited to 'src/corelib/io/qresource.cpp')
-rw-r--r-- | src/corelib/io/qresource.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index b85bca8590..8c1bfc8c48 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1503,14 +1503,25 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory { Q_Q(QResourceFileEngine); Q_UNUSED(flags); + + qint64 max = resource.size(); + if (resource.isCompressed()) { + uncompress(); + max = uncompressed.size(); + } + qint64 end; if (offset < 0 || size <= 0 || !resource.isValid() || - add_overflow(offset, size, &end) || end > resource.size()) { + add_overflow(offset, size, &end) || end > max) { q->setError(QFile::UnspecifiedError, QString()); return 0; } - uchar *address = const_cast<uchar *>(resource.data()); - return (address + offset); + + const uchar *address = resource.data(); + if (resource.isCompressed()) + address = reinterpret_cast<const uchar *>(uncompressed.constData()); + + return const_cast<uchar *>(address) + offset; } bool QResourceFileEnginePrivate::unmap(uchar *ptr) |