]> git.lizzy.rs Git - zlib.git/blobdiff - uncompr.c
Change version number to 1.2.7.3.
[zlib.git] / uncompr.c
index b423696d64b7c99fe97cad3f17048222951be574..242e9493dff5c26d7f06104b6dd1ca22d8201215 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
@@ -1,10 +1,11 @@
 /* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995 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;
-    Bytef *source;
+    const Bytef *source;
     uLong sourceLen;
 {
     z_stream stream;
     int err;
 
-    stream.next_in = source;
+    stream.next_in = (z_const Bytef *)source;
     stream.avail_in = (uInt)sourceLen;
     /* Check for source > 64K on 16-bit machine: */
     if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
@@ -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;