Commit 8e20ba2e authored by Lasse Collin's avatar Lasse Collin Committed by Linus Torvalds
Browse files

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.


Signed-off-by: default avatarLasse Collin <>
Reported-by: default avatarYu Sun <>
Acked-by: default avatarDaniel Walker <>
Cc: "Yixia Si (yisi)" <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 82072962
......@@ -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;
s->dict.buf = vmalloc(s->dict.size);
if (s->dict.buf == NULL) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment