aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJohannes Schickel2012-07-15 02:36:47 +0200
committerJohannes Schickel2013-01-26 15:25:13 +0100
commit36bfaa6a308654862c5d233fe4e86d9f8c4c02bd (patch)
treeb558ee150e3af5d061379fd1b941c91dfd41f8ef /common
parent69424b71bd027e4eb29ecadaca5271c5d677cac3 (diff)
downloadscummvm-rg350-36bfaa6a308654862c5d233fe4e86d9f8c4c02bd.tar.gz
scummvm-rg350-36bfaa6a308654862c5d233fe4e86d9f8c4c02bd.tar.bz2
scummvm-rg350-36bfaa6a308654862c5d233fe4e86d9f8c4c02bd.zip
COMMON: Return NULL in wrapCompressedReadStream for compressed streams when ZLIB is disabled.
Diffstat (limited to 'common')
-rw-r--r--common/zlib.cpp10
-rw-r--r--common/zlib.h4
2 files changed, 10 insertions, 4 deletions
diff --git a/common/zlib.cpp b/common/zlib.cpp
index fc8f351054..62904cb150 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -392,17 +392,21 @@ public:
#endif // USE_ZLIB
SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize) {
-#if defined(USE_ZLIB)
if (toBeWrapped) {
uint16 header = toBeWrapped->readUint16BE();
bool isCompressed = (header == 0x1F8B ||
((header & 0x0F00) == 0x0800 &&
header % 31 == 0));
toBeWrapped->seek(-2, SEEK_CUR);
- if (isCompressed)
+ if (isCompressed) {
+#if defined(USE_ZLIB)
return new GZipReadStream(toBeWrapped, knownSize);
- }
+#else
+ delete toBeWrapped;
+ return NULL;
#endif
+ }
+ }
return toBeWrapped;
}
diff --git a/common/zlib.h b/common/zlib.h
index 6a840f5fdc..2772ffba06 100644
--- a/common/zlib.h
+++ b/common/zlib.h
@@ -103,7 +103,9 @@ bool inflateZlibInstallShield(byte *dst, uint dstLen, const byte *src, uint srcL
* provides transparent on-the-fly decompression. Assumes the data it
* retrieves from the wrapped stream to be either uncompressed or in gzip
* format. In the former case, the original stream is returned unmodified
- * (and in particular, not wrapped).
+ * (and in particular, not wrapped). In the latter case the stream is
+ * returned wrapped, unless there is no ZLIB support, then NULL is returned
+ * and the old stream is destroyed.
*
* Certain GZip-formats don't supply an easily readable length, if you
* still need the length carried along with the stream, and you know