]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix integer overflow warning
authorMika Lindqvist <postmaster@raasu.org>
Tue, 12 May 2015 23:21:25 +0000 (02:21 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Wed, 13 May 2015 06:46:27 +0000 (08:46 +0200)
* Move declaration of "plevel" below declaration of "level"

test/minigzip.c

index 4e589c2f7b8ade6bce97729701e914390ca88b97..80f4c12c99fb17877d6d88189926ced1232947bc 100644 (file)
@@ -101,6 +101,7 @@ gzFile gz_open(const char *path, int fd, const char *mode)
     gzFile gz;
     int ret;
     int level = Z_DEFAULT_COMPRESSION;
+    const char *plevel = mode;
 
     gz = malloc(sizeof(struct gzFile_s));
     if (gz == NULL)
@@ -110,7 +111,6 @@ gzFile gz_open(const char *path, int fd, const char *mode)
     gz->strm.zfree = myfree;
     gz->strm.opaque = Z_NULL;
 
-    const char *plevel = mode;
     while (*plevel) {
         if (*plevel >= '0' && *plevel <= '9') {
            level = *plevel - '0';
@@ -167,7 +167,7 @@ int gzread (gzFile, void *, unsigned);
 int gzread(gzFile gz, void *buf, unsigned len)
 {
     int ret;
-    unsigned got;
+    size_t got;
     unsigned char in[1];
     z_stream *strm;