Fix the warnings I created.
[project/opkg-lede.git] / libbb / unzip.c
index 08c17d4a2927877a7ad10f85b2791eafd8eda4e7..186da594a45c8fff04bb3748fbd769cf391615a1 100644 (file)
@@ -45,6 +45,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include "libbb.h"
 
 static FILE *in_file, *out_file;
@@ -98,7 +99,7 @@ static const unsigned short mask_bits[] = {
 static void abort_gzip()
 {
        error_msg("gzip aborted\n");
-       exit(ERROR);
+       _exit(ERROR);
 }
 
 static void make_crc_table()
@@ -113,7 +114,7 @@ static void make_crc_table()
 
        /* initial shift register value */
        crc = 0xffffffffL;      
-       crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));
+       crc_table = (unsigned long *) xmalloc(256 * sizeof(unsigned long));
 
        /* Make exclusive-or pattern from polynomial (0xedb88320) */
        for (i = 0; i < sizeof(p)/sizeof(int); i++)
@@ -148,7 +149,8 @@ static void flush_window(void)
        }
 
        if (fwrite(window, 1, outcnt, out_file) != outcnt) {
-               error_msg_and_die("Couldnt write");
+               error_msg("Couldnt write");
+               _exit(EXIT_FAILURE);
        }
        bytes_out += (unsigned long) outcnt;
        outcnt = 0;
@@ -639,8 +641,11 @@ static int inflate_block(int *e)
                        }
 
                        /* decompress until an end-of-block code */
-                       if (inflate_codes(tl, td, bl, bd))
+                       if (inflate_codes(tl, td, bl, bd)) {
+                               huft_free(tl);
+                               huft_free(td);
                                return 1;
+                       }
 
                        /* free the decoding tables, return */
                        huft_free(tl);
@@ -816,8 +821,11 @@ static int inflate_block(int *e)
                        }
 
                        /* decompress until an end-of-block code */
-                       if (inflate_codes(tl, td, bl, bd))
+                       if (inflate_codes(tl, td, bl, bd)) {
+                               huft_free(tl);
+                               huft_free(td);
                                return 1;
+                       }
 
                        /* free the decoding tables, return */
                        huft_free(tl);
@@ -1005,19 +1013,3 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
 
        return exit_code;
 }
-
-/*
- * This needs access to global variables wondow and crc_table, so its not in its own file.
- */
-extern void gz_close(int gunzip_pid)
-{
-       if (kill(gunzip_pid, SIGTERM) == -1) {
-               error_msg_and_die("***  Couldnt kill old gunzip process *** aborting");
-       }
-
-       if (waitpid(gunzip_pid, NULL, 0) == -1) {
-               printf("Couldnt wait ?");
-       }
-               free(window);
-               free(crc_table);
-}