Imported Upstream version 1.3.14
[debian/gzip] / inflate.c
index 9f3a6616e18e1ca70eaa0c1b88bde43a0209211c..b72c187ee38315c604b236357bee2d33f030f299 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1,11 +1,10 @@
 /* Inflate deflated data
 
 /* Inflate deflated data
 
-   Copyright (C) 1997, 1998, 1999, 2002, 2006 Free Software
-   Foundation, Inc.
+   Copyright (C) 1997-1999, 2002, 2006, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    any later version.
 
    This program is distributed in the hope that it will be useful,
       the two sets of lengths.
  */
 
       the two sets of lengths.
  */
 
-#ifdef RCSID
-static char rcsid[] = "$Id: inflate.c,v 1.6 2006/12/20 23:30:17 eggert Exp $";
-#endif
-
 #include <config.h>
 #include "tailor.h"
 
 #include <config.h>
 #include "tailor.h"
 
@@ -335,13 +330,15 @@ int *m;                 /* maximum lookup bits, returns actual */
   } while (--i);
   if (c[0] == n)                /* null input--all zero length codes */
   {
   } while (--i);
   if (c[0] == n)                /* null input--all zero length codes */
   {
-    q = (struct huft *) malloc (2 * sizeof *q);
+    q = (struct huft *) malloc (3 * sizeof *q);
     if (!q)
       return 3;
     if (!q)
       return 3;
-    hufts += 2;
+    hufts += 3;
     q[0].v.t = (struct huft *) NULL;
     q[1].e = 99;    /* invalid code marker */
     q[1].b = 1;
     q[0].v.t = (struct huft *) NULL;
     q[1].e = 99;    /* invalid code marker */
     q[1].b = 1;
+    q[2].e = 99;    /* invalid code marker */
+    q[2].b = 1;
     *t = q + 1;
     *m = 1;
     return 0;
     *t = q + 1;
     *m = 1;
     return 0;
@@ -510,7 +507,7 @@ struct huft *t;         /* table to free */
   while (p != (struct huft *)NULL)
   {
     q = (--p)->v.t;
   while (p != (struct huft *)NULL)
   {
     q = (--p)->v.t;
-    free((char*)p);
+    free(p);
     p = q;
   }
   return 0;
     p = q;
   }
   return 0;
@@ -885,15 +882,16 @@ int inflate_dynamic()
   }
 
 
   }
 
 
-  /* decompress until an end-of-block code */
-  if (inflate_codes(tl, td, bl, bd))
-    return 1;
+  {
+    /* decompress until an end-of-block code */
+    int err = inflate_codes(tl, td, bl, bd) ? 1 : 0;
 
 
+    /* free the decoding tables */
+    huft_free(tl);
+    huft_free(td);
 
 
-  /* free the decoding tables, return */
-  huft_free(tl);
-  huft_free(td);
-  return 0;
+    return err;
+  }
 }
 
 
 }