X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=inflate.c;h=75353e2d72b50f0fb48d51a5ef6498d324dbf901;hb=e28b2e55253c37dfcbf8c70604abc58095a77d40;hp=2f4954be020fd9a9eaf0da4015ca8ee465e6dcc5;hpb=91ce7f143f4e5b51f809b4d4dbb1eba030843726;p=debian%2Fgzip diff --git a/inflate.c b/inflate.c index 2f4954b..75353e2 100644 --- a/inflate.c +++ b/inflate.c @@ -1,11 +1,11 @@ /* Inflate deflated data - Copyright (C) 1997, 1998, 1999, 2002, 2006 Free Software - Foundation, Inc. + Copyright (C) 1997-1999, 2002, 2006, 2009-2010 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 - 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, @@ -115,16 +115,10 @@ 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 #include "tailor.h" -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#endif +#include #include "gzip.h" #define slide window @@ -512,7 +506,7 @@ struct huft *t; /* table to free */ while (p != (struct huft *)NULL) { q = (--p)->v.t; - free((char*)p); + free(p); p = q; } return 0; @@ -595,7 +589,8 @@ int bl, bd; /* number of bits decoded by tl[] and td[] */ do { n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); #if !defined(NOMEMCPY) && !defined(DEBUG) - if (w - d >= e) /* (this test assumes unsigned comparison) */ + unsigned int delta = w > d ? w - d : d - w; + if (delta >= e) { memcpy(slide + w, slide + d, e); w += e; @@ -887,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; + } }