Skip to content

Commit 8e20ba2

Browse files
Larhzutorvalds
authored andcommitted
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]>
1 parent 8207296 commit 8e20ba2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/xz/xz_dec_lzma2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
11461146

11471147
if (DEC_IS_DYNALLOC(s->dict.mode)) {
11481148
if (s->dict.allocated < s->dict.size) {
1149+
s->dict.allocated = s->dict.size;
11491150
vfree(s->dict.buf);
11501151
s->dict.buf = vmalloc(s->dict.size);
11511152
if (s->dict.buf == NULL) {

0 commit comments

Comments
 (0)