diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-11-02 13:54:26 -0700 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-11-19 09:09:31 +0000 |
commit | 6a792d6f0b5a15ce09b7883bbbb06b2724596e40 (patch) | |
tree | 27d8849f535946a6e7d0b6ff43b7a9c94c5097da /src | |
parent | 460866ee47c2a2ee98d7874a88bc3cc4b17b6f6a (diff) |
QResourceFileEngine: fix map() for compressed files
We were returning a pointer to the compressed data and comparing to the
compressed data size.
Change-Id: I343f2beed55440a7ac0bfffd1563232d557c9427
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-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) |