]> git.lizzy.rs Git - zlib.git/blobdiff - uncompr.c
Remove hard-coding of resource compiler in CMakeLists.txt [Blammo]
[zlib.git] / uncompr.c
index 3431561d8abb867b7641016566fdb49975ecbff1..ad98be3a5d88afd479d3442cd234747ca259c60d 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
@@ -1,10 +1,11 @@
 /* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-1996 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h 
+ * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-/* $Id: uncompr.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */
+/* @(#) $Id$ */
 
+#define ZLIB_INTERNAL
 #include "zlib.h"
 
 /* ===========================================================================
    been saved previously by the compressor and transmitted to the decompressor
    by some mechanism outside the scope of this compression library.)
    Upon exit, destLen is the actual size of the compressed buffer.
-     This function can be used to decompress a whole file at once if the
-   input file is mmap'ed.
 
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_BUF_ERROR if there was not enough room in the output
    buffer, or Z_DATA_ERROR if the input data was corrupted.
 */
-int uncompress (dest, destLen, source, sourceLen)
+int ZEXPORT uncompress (dest, destLen, source, sourceLen)
     Bytef *dest;
     uLongf *destLen;
     const Bytef *source;
@@ -49,6 +48,8 @@ int uncompress (dest, destLen, source, sourceLen)
     err = inflate(&stream, Z_FINISH);
     if (err != Z_STREAM_END) {
         inflateEnd(&stream);
+        if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
+            return Z_DATA_ERROR;
         return err;
     }
     *destLen = stream.total_out;