diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /lib/decompress_bunzip2.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'lib/decompress_bunzip2.c')
-rw-r--r-- | lib/decompress_bunzip2.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c index 600f473a5610..a4e971dee102 100644 --- a/lib/decompress_bunzip2.c +++ b/lib/decompress_bunzip2.c | |||
@@ -299,7 +299,7 @@ static int INIT get_next_block(struct bunzip_data *bd) | |||
299 | again when using them (during symbol decoding).*/ | 299 | again when using them (during symbol decoding).*/ |
300 | base = hufGroup->base-1; | 300 | base = hufGroup->base-1; |
301 | limit = hufGroup->limit-1; | 301 | limit = hufGroup->limit-1; |
302 | /* Calculate permute[]. Concurently, initialize | 302 | /* Calculate permute[]. Concurrently, initialize |
303 | * temp[] and limit[]. */ | 303 | * temp[] and limit[]. */ |
304 | pp = 0; | 304 | pp = 0; |
305 | for (i = minLen; i <= maxLen; i++) { | 305 | for (i = minLen; i <= maxLen; i++) { |
@@ -637,6 +637,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, | |||
637 | 637 | ||
638 | /* Allocate bunzip_data. Most fields initialize to zero. */ | 638 | /* Allocate bunzip_data. Most fields initialize to zero. */ |
639 | bd = *bdp = malloc(i); | 639 | bd = *bdp = malloc(i); |
640 | if (!bd) | ||
641 | return RETVAL_OUT_OF_MEMORY; | ||
640 | memset(bd, 0, sizeof(struct bunzip_data)); | 642 | memset(bd, 0, sizeof(struct bunzip_data)); |
641 | /* Setup input buffer */ | 643 | /* Setup input buffer */ |
642 | bd->inbuf = inbuf; | 644 | bd->inbuf = inbuf; |
@@ -664,6 +666,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, | |||
664 | bd->dbufSize = 100000*(i-BZh0); | 666 | bd->dbufSize = 100000*(i-BZh0); |
665 | 667 | ||
666 | bd->dbuf = large_malloc(bd->dbufSize * sizeof(int)); | 668 | bd->dbuf = large_malloc(bd->dbufSize * sizeof(int)); |
669 | if (!bd->dbuf) | ||
670 | return RETVAL_OUT_OF_MEMORY; | ||
667 | return RETVAL_OK; | 671 | return RETVAL_OK; |
668 | } | 672 | } |
669 | 673 | ||
@@ -686,7 +690,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, | |||
686 | 690 | ||
687 | if (!outbuf) { | 691 | if (!outbuf) { |
688 | error("Could not allocate output bufer"); | 692 | error("Could not allocate output bufer"); |
689 | return -1; | 693 | return RETVAL_OUT_OF_MEMORY; |
690 | } | 694 | } |
691 | if (buf) | 695 | if (buf) |
692 | inbuf = buf; | 696 | inbuf = buf; |
@@ -694,6 +698,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, | |||
694 | inbuf = malloc(BZIP2_IOBUF_SIZE); | 698 | inbuf = malloc(BZIP2_IOBUF_SIZE); |
695 | if (!inbuf) { | 699 | if (!inbuf) { |
696 | error("Could not allocate input bufer"); | 700 | error("Could not allocate input bufer"); |
701 | i = RETVAL_OUT_OF_MEMORY; | ||
697 | goto exit_0; | 702 | goto exit_0; |
698 | } | 703 | } |
699 | i = start_bunzip(&bd, inbuf, len, fill); | 704 | i = start_bunzip(&bd, inbuf, len, fill); |
@@ -720,11 +725,14 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, | |||
720 | } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) { | 725 | } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) { |
721 | error("Compressed file ends unexpectedly"); | 726 | error("Compressed file ends unexpectedly"); |
722 | } | 727 | } |
728 | if (!bd) | ||
729 | goto exit_1; | ||
723 | if (bd->dbuf) | 730 | if (bd->dbuf) |
724 | large_free(bd->dbuf); | 731 | large_free(bd->dbuf); |
725 | if (pos) | 732 | if (pos) |
726 | *pos = bd->inbufPos; | 733 | *pos = bd->inbufPos; |
727 | free(bd); | 734 | free(bd); |
735 | exit_1: | ||
728 | if (!buf) | 736 | if (!buf) |
729 | free(inbuf); | 737 | free(inbuf); |
730 | exit_0: | 738 | exit_0: |