aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2019-10-30 18:26:56 +0200
committerLasse Collin <lasse.collin@tukaani.org>2019-10-30 18:26:56 +0200
commit40d291b609d0cc6344f3e26ed34b4fd755e403da (patch)
treedc66800971ca2a458e42cb69262b3d422c53b080
parent525549dce62c134ebe26255deab0eb795d92599d (diff)
downloadxz-embedded-40d291b609d0cc6344f3e26ed34b4fd755e403da.tar.gz
Fix XZ_DYN_ALLOC to avoid useless memory reallocations.
s->dict.allocated was initialized to 0 but never set after a successful allocation, thus the code always thought that the dictionary buffer has to be reallocated. Thanks to Yu Sun from Cisco Systems for reporting this bug.
-rw-r--r--linux/lib/xz/xz_dec_lzma2.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/linux/lib/xz/xz_dec_lzma2.c b/linux/lib/xz/xz_dec_lzma2.c
index 08c3c80..156f26f 100644
--- a/linux/lib/xz/xz_dec_lzma2.c
+++ b/linux/lib/xz/xz_dec_lzma2.c
@@ -1146,6 +1146,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
if (DEC_IS_DYNALLOC(s->dict.mode)) {
if (s->dict.allocated < s->dict.size) {
+ s->dict.allocated = s->dict.size;
vfree(s->dict.buf);
s->dict.buf = vmalloc(s->dict.size);
if (s->dict.buf == NULL) {