diff options
author | akirilov <akirilov@google.com> | 2018-06-01 13:46:04 -0700 |
---|---|---|
committer | syphyr <syphyr@gmail.com> | 2018-09-06 04:08:09 +0200 |
commit | 126c3993d2ad55db2abfe80e3d671bf584e7b13b (patch) | |
tree | f4464c225863c997e3f99d9897131f9f28df76fe /xzlib.c | |
parent | 521b88fbb6d18312923f0df653d045384b500ffc (diff) | |
download | android_external_libxml2-cm-13.0.tar.gz android_external_libxml2-cm-13.0.tar.bz2 android_external_libxml2-cm-13.0.zip |
RESTRICT AUTOMERGE: Update libxml2 to 2.9.8HEADreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5replicant-6.0-0004-rc4replicant-6.0-0004-rc3replicant-6.0-0004-rc2replicant-6.0-0004cm-14.1cm-13.0
Merge to pi-dev and restore Android.mk
Bug: 79662501
Bug: 36809766
Bug: 36810305
Bug: 62151041
Test: manually verify functionality for regression
Change-Id: Ife351c91c932eb92992656f8ea5c08724a220306
(cherry picked from commit 4e91cfdbb1a8624e5cd5a850d6e17da11d1e34a8)
Diffstat (limited to 'xzlib.c')
-rw-r--r-- | xzlib.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -31,10 +31,10 @@ #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED #include <zlib.h> #endif -#ifdef HAVE_LZMA_H +#ifdef LIBXML_LZMA_ENABLED #include <lzma.h> #endif @@ -76,7 +76,7 @@ typedef struct { char padding1[32]; /* padding allowing to cope with possible extensions of above structure without too much side effect */ -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED /* zlib inflate or deflate stream */ z_stream zstrm; /* stream structure in-place (not a pointer) */ #endif @@ -130,7 +130,7 @@ xz_reset(xz_statep state) xz_error(state, LZMA_OK, NULL); /* clear error */ state->pos = 0; /* no uncompressed data yet */ state->strm.avail_in = 0; /* no input data yet */ -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED state->zstrm.avail_in = 0; /* no input data yet */ #endif } @@ -272,7 +272,7 @@ xz_avail(xz_statep state) return 0; } -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED static int xz_avail_zstrm(xz_statep state) { @@ -349,7 +349,7 @@ is_format_lzma(xz_statep state) return 1; } -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED /* Get next byte from input, or -1 if end or error. */ #define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \ @@ -408,14 +408,14 @@ xz_head(xz_statep state) state->strm = init; state->strm.avail_in = 0; state->strm.next_in = NULL; - if (lzma_auto_decoder(&state->strm, UINT64_MAX, 0) != LZMA_OK) { + if (lzma_auto_decoder(&state->strm, 100000000, 0) != LZMA_OK) { xmlFree(state->out); xmlFree(state->in); state->size = 0; xz_error(state, LZMA_MEM_ERROR, "out of memory"); return -1; } -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED /* allocate inflate memory */ state->zstrm.zalloc = Z_NULL; state->zstrm.zfree = Z_NULL; @@ -449,7 +449,7 @@ xz_head(xz_statep state) state->direct = 0; return 0; } -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED /* look for the gzip magic header bytes 31 and 139 */ if (strm->next_in[0] == 31) { strm->avail_in--; @@ -550,7 +550,7 @@ xz_decomp(xz_statep state) action = LZMA_FINISH; /* decompress and handle errors */ -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED if (state->how == GZIP) { state->zstrm.avail_in = (uInt) state->strm.avail_in; state->zstrm.next_in = (Bytef *) state->strm.next_in; @@ -592,13 +592,13 @@ xz_decomp(xz_statep state) /* update available output and crc check value */ state->have = had - strm->avail_out; state->next = strm->next_out - state->have; -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED state->zstrm.adler = crc32(state->zstrm.adler, state->next, state->have); #endif if (ret == LZMA_STREAM_END) { -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED if (state->how == GZIP) { if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) { xz_error(state, LZMA_DATA_ERROR, "unexpected end of file"); @@ -788,7 +788,7 @@ __libxml2_xzclose(xzFile file) /* free memory and close file */ if (state->size) { lzma_end(&(state->strm)); -#ifdef HAVE_ZLIB_H +#ifdef LIBXML_ZLIB_ENABLED if (state->init == 1) inflateEnd(&(state->zstrm)); state->init = 0; @@ -797,6 +797,8 @@ __libxml2_xzclose(xzFile file) xmlFree(state->in); } xmlFree(state->path); + if ((state->msg != NULL) && (state->err != LZMA_MEM_ERROR)) + xmlFree(state->msg); ret = close(state->fd); xmlFree(state); return ret ? ret : LZMA_OK; |