diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-05-02 13:27:15 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:15 -0400 |
commit | 39b7ee06859b07ca5fd4fabb44c4600316532574 (patch) | |
tree | 938d2e25cdf8068e9604dc40775aede665f6e98b | |
parent | 35c7422649ee7a3d0eb4ebd32c997eeb45f81046 (diff) |
[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: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
-rw-r--r-- | lib/inflate.c | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/lib/inflate.c b/lib/inflate.c index 88a22f4a49df..845f91d3ac12 100644 --- a/lib/inflate.c +++ b/lib/inflate.c | |||
@@ -798,16 +798,19 @@ STATIC int noinline INIT inflate_dynamic(void) | |||
798 | unsigned nb; /* number of bit length codes */ | 798 | unsigned nb; /* number of bit length codes */ |
799 | unsigned nl; /* number of literal/length codes */ | 799 | unsigned nl; /* number of literal/length codes */ |
800 | unsigned nd; /* number of distance codes */ | 800 | unsigned nd; /* number of distance codes */ |
801 | #ifdef PKZIP_BUG_WORKAROUND | 801 | unsigned *ll; /* literal/length and distance code lengths */ |
802 | unsigned ll[288+32]; /* literal/length and distance code lengths */ | ||
803 | #else | ||
804 | unsigned ll[286+30]; /* literal/length and distance code lengths */ | ||
805 | #endif | ||
806 | register ulg b; /* bit buffer */ | 802 | register ulg b; /* bit buffer */ |
807 | register unsigned k; /* number of bits in bit buffer */ | 803 | register unsigned k; /* number of bits in bit buffer */ |
804 | int ret; | ||
808 | 805 | ||
809 | DEBG("<dyn"); | 806 | DEBG("<dyn"); |
810 | 807 | ||
808 | #ifdef PKZIP_BUG_WORKAROUND | ||
809 | ll = malloc(sizeof(*ll) * (288+32)); /* literal/length and distance code lengths */ | ||
810 | #else | ||
811 | ll = malloc(sizeof(*ll) * (286+30)); /* literal/length and distance code lengths */ | ||
812 | #endif | ||
813 | |||
811 | /* make local bit buffer */ | 814 | /* make local bit buffer */ |
812 | b = bb; | 815 | b = bb; |
813 | k = bk; | 816 | k = bk; |
@@ -828,7 +831,10 @@ DEBG("<dyn"); | |||
828 | #else | 831 | #else |
829 | if (nl > 286 || nd > 30) | 832 | if (nl > 286 || nd > 30) |
830 | #endif | 833 | #endif |
831 | return 1; /* bad lengths */ | 834 | { |
835 | ret = 1; /* bad lengths */ | ||
836 | goto out; | ||
837 | } | ||
832 | 838 | ||
833 | DEBG("dyn1 "); | 839 | DEBG("dyn1 "); |
834 | 840 | ||
@@ -850,7 +856,8 @@ DEBG("dyn2 "); | |||
850 | { | 856 | { |
851 | if (i == 1) | 857 | if (i == 1) |
852 | huft_free(tl); | 858 | huft_free(tl); |
853 | return i; /* incomplete code set */ | 859 | ret = i; /* incomplete code set */ |
860 | goto out; | ||
854 | } | 861 | } |
855 | 862 | ||
856 | DEBG("dyn3 "); | 863 | DEBG("dyn3 "); |
@@ -872,8 +879,10 @@ DEBG("dyn3 "); | |||
872 | NEEDBITS(2) | 879 | NEEDBITS(2) |
873 | j = 3 + ((unsigned)b & 3); | 880 | j = 3 + ((unsigned)b & 3); |
874 | DUMPBITS(2) | 881 | DUMPBITS(2) |
875 | if ((unsigned)i + j > n) | 882 | if ((unsigned)i + j > n) { |
876 | return 1; | 883 | ret = 1; |
884 | goto out; | ||
885 | } | ||
877 | while (j--) | 886 | while (j--) |
878 | ll[i++] = l; | 887 | ll[i++] = l; |
879 | } | 888 | } |
@@ -882,8 +891,10 @@ DEBG("dyn3 "); | |||
882 | NEEDBITS(3) | 891 | NEEDBITS(3) |
883 | j = 3 + ((unsigned)b & 7); | 892 | j = 3 + ((unsigned)b & 7); |
884 | DUMPBITS(3) | 893 | DUMPBITS(3) |
885 | if ((unsigned)i + j > n) | 894 | if ((unsigned)i + j > n) { |
886 | return 1; | 895 | ret = 1; |
896 | goto out; | ||
897 | } | ||
887 | while (j--) | 898 | while (j--) |
888 | ll[i++] = 0; | 899 | ll[i++] = 0; |
889 | l = 0; | 900 | l = 0; |
@@ -893,8 +904,10 @@ DEBG("dyn3 "); | |||
893 | NEEDBITS(7) | 904 | NEEDBITS(7) |
894 | j = 11 + ((unsigned)b & 0x7f); | 905 | j = 11 + ((unsigned)b & 0x7f); |
895 | DUMPBITS(7) | 906 | DUMPBITS(7) |
896 | if ((unsigned)i + j > n) | 907 | if ((unsigned)i + j > n) { |
897 | return 1; | 908 | ret = 1; |
909 | goto out; | ||
910 | } | ||
898 | while (j--) | 911 | while (j--) |
899 | ll[i++] = 0; | 912 | ll[i++] = 0; |
900 | l = 0; | 913 | l = 0; |
@@ -923,7 +936,8 @@ DEBG("dyn5b "); | |||
923 | error("incomplete literal tree"); | 936 | error("incomplete literal tree"); |
924 | huft_free(tl); | 937 | huft_free(tl); |
925 | } | 938 | } |
926 | return i; /* incomplete code set */ | 939 | ret = i; /* incomplete code set */ |
940 | goto out; | ||
927 | } | 941 | } |
928 | DEBG("dyn5c "); | 942 | DEBG("dyn5c "); |
929 | bd = dbits; | 943 | bd = dbits; |
@@ -939,15 +953,18 @@ DEBG("dyn5d "); | |||
939 | huft_free(td); | 953 | huft_free(td); |
940 | } | 954 | } |
941 | huft_free(tl); | 955 | huft_free(tl); |
942 | return i; /* incomplete code set */ | 956 | ret = i; /* incomplete code set */ |
957 | goto out; | ||
943 | #endif | 958 | #endif |
944 | } | 959 | } |
945 | 960 | ||
946 | DEBG("dyn6 "); | 961 | DEBG("dyn6 "); |
947 | 962 | ||
948 | /* decompress until an end-of-block code */ | 963 | /* decompress until an end-of-block code */ |
949 | if (inflate_codes(tl, td, bl, bd)) | 964 | if (inflate_codes(tl, td, bl, bd)) { |
950 | return 1; | 965 | ret = 1; |
966 | goto out; | ||
967 | } | ||
951 | 968 | ||
952 | DEBG("dyn7 "); | 969 | DEBG("dyn7 "); |
953 | 970 | ||
@@ -956,10 +973,14 @@ DEBG("dyn7 "); | |||
956 | huft_free(td); | 973 | huft_free(td); |
957 | 974 | ||
958 | DEBG(">"); | 975 | DEBG(">"); |
959 | return 0; | 976 | ret = 0; |
977 | out: | ||
978 | free(ll); | ||
979 | return ret; | ||
960 | 980 | ||
961 | underrun: | 981 | underrun: |
962 | return 4; /* Input underrun */ | 982 | ret = 4; /* Input underrun */ |
983 | goto out; | ||
963 | } | 984 | } |
964 | 985 | ||
965 | 986 | ||