Commit 39b7ee06 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Andi Kleen

[PATCH] x86-64: deflate inflate_dynamic too

inflate_dynamic() has piggy stack usage too, so heap allocate it too.
I'm not sure it actually gets used, but it shows up large in "make
checkstack".
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent 35c74226
...@@ -798,16 +798,19 @@ STATIC int noinline INIT inflate_dynamic(void) ...@@ -798,16 +798,19 @@ STATIC int noinline INIT inflate_dynamic(void)
unsigned nb; /* number of bit length codes */ unsigned nb; /* number of bit length codes */
unsigned nl; /* number of literal/length codes */ unsigned nl; /* number of literal/length codes */
unsigned nd; /* number of distance codes */ unsigned nd; /* number of distance codes */
#ifdef PKZIP_BUG_WORKAROUND unsigned *ll; /* literal/length and distance code lengths */
unsigned ll[288+32]; /* literal/length and distance code lengths */
#else
unsigned ll[286+30]; /* literal/length and distance code lengths */
#endif
register ulg b; /* bit buffer */ register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */ register unsigned k; /* number of bits in bit buffer */
int ret;
DEBG("<dyn"); DEBG("<dyn");
#ifdef PKZIP_BUG_WORKAROUND
ll = malloc(sizeof(*ll) * (288+32)); /* literal/length and distance code lengths */
#else
ll = malloc(sizeof(*ll) * (286+30)); /* literal/length and distance code lengths */
#endif
/* make local bit buffer */ /* make local bit buffer */
b = bb; b = bb;
k = bk; k = bk;
...@@ -828,7 +831,10 @@ DEBG("<dyn"); ...@@ -828,7 +831,10 @@ DEBG("<dyn");
#else #else
if (nl > 286 || nd > 30) if (nl > 286 || nd > 30)
#endif #endif
return 1; /* bad lengths */ {
ret = 1; /* bad lengths */
goto out;
}
DEBG("dyn1 "); DEBG("dyn1 ");
...@@ -850,7 +856,8 @@ DEBG("dyn2 "); ...@@ -850,7 +856,8 @@ DEBG("dyn2 ");
{ {
if (i == 1) if (i == 1)
huft_free(tl); huft_free(tl);
return i; /* incomplete code set */ ret = i; /* incomplete code set */
goto out;
} }
DEBG("dyn3 "); DEBG("dyn3 ");
...@@ -872,8 +879,10 @@ DEBG("dyn3 "); ...@@ -872,8 +879,10 @@ DEBG("dyn3 ");
NEEDBITS(2) NEEDBITS(2)
j = 3 + ((unsigned)b & 3); j = 3 + ((unsigned)b & 3);
DUMPBITS(2) DUMPBITS(2)
if ((unsigned)i + j > n) if ((unsigned)i + j > n) {
return 1; ret = 1;
goto out;
}
while (j--) while (j--)
ll[i++] = l; ll[i++] = l;
} }
...@@ -882,8 +891,10 @@ DEBG("dyn3 "); ...@@ -882,8 +891,10 @@ DEBG("dyn3 ");
NEEDBITS(3) NEEDBITS(3)
j = 3 + ((unsigned)b & 7); j = 3 + ((unsigned)b & 7);
DUMPBITS(3) DUMPBITS(3)
if ((unsigned)i + j > n) if ((unsigned)i + j > n) {
return 1; ret = 1;
goto out;
}
while (j--) while (j--)
ll[i++] = 0; ll[i++] = 0;
l = 0; l = 0;
...@@ -893,8 +904,10 @@ DEBG("dyn3 "); ...@@ -893,8 +904,10 @@ DEBG("dyn3 ");
NEEDBITS(7) NEEDBITS(7)
j = 11 + ((unsigned)b & 0x7f); j = 11 + ((unsigned)b & 0x7f);
DUMPBITS(7) DUMPBITS(7)
if ((unsigned)i + j > n) if ((unsigned)i + j > n) {
return 1; ret = 1;
goto out;
}
while (j--) while (j--)
ll[i++] = 0; ll[i++] = 0;
l = 0; l = 0;
...@@ -923,7 +936,8 @@ DEBG("dyn5b "); ...@@ -923,7 +936,8 @@ DEBG("dyn5b ");
error("incomplete literal tree"); error("incomplete literal tree");
huft_free(tl); huft_free(tl);
} }
return i; /* incomplete code set */ ret = i; /* incomplete code set */
goto out;
} }
DEBG("dyn5c "); DEBG("dyn5c ");
bd = dbits; bd = dbits;
...@@ -939,15 +953,18 @@ DEBG("dyn5d "); ...@@ -939,15 +953,18 @@ DEBG("dyn5d ");
huft_free(td); huft_free(td);
} }
huft_free(tl); huft_free(tl);
return i; /* incomplete code set */ ret = i; /* incomplete code set */
goto out;
#endif #endif
} }
DEBG("dyn6 "); DEBG("dyn6 ");
/* decompress until an end-of-block code */ /* decompress until an end-of-block code */
if (inflate_codes(tl, td, bl, bd)) if (inflate_codes(tl, td, bl, bd)) {
return 1; ret = 1;
goto out;
}
DEBG("dyn7 "); DEBG("dyn7 ");
...@@ -956,10 +973,14 @@ DEBG("dyn7 "); ...@@ -956,10 +973,14 @@ DEBG("dyn7 ");
huft_free(td); huft_free(td);
DEBG(">"); DEBG(">");
return 0; ret = 0;
out:
free(ll);
return ret;
underrun: underrun:
return 4; /* Input underrun */ ret = 4; /* Input underrun */
goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment