aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <[email protected]>2019-11-15 17:34:39 -0800
committerLinus Torvalds <[email protected]>2019-11-15 18:34:00 -0800
commit8e20ba2e53fc6198cbfbcc700e9f884157052a8d (patch)
tree8e9a6ff8aea2fb572ba1a3e6b964ff9eb9f7efab
parent82072962973008201b817fae1896512977dd5083 (diff)
lib/xz: fix XZ_DYNALLOC 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. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Lasse Collin <[email protected]> Reported-by: Yu Sun <[email protected]> Acked-by: Daniel Walker <[email protected]> Cc: "Yixia Si (yisi)" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--lib/xz/xz_dec_lzma2.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
index 08c3c8049998..156f26fdc4c9 100644
--- a/lib/xz/xz_dec_lzma2.c
+++ b/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) {