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/20191104185107.3b6330df@tukaani.org Signed-off-by: Lasse Collin <lasse.collin@tukaani.org> Reported-by: Yu Sun <yusun2@cisco.com> Acked-by: Daniel Walker <danielwa@cisco.com> Cc: "Yixia Si (yisi)" <yisi@cisco.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
8207296297
Коммит
8e20ba2e53
|
@ -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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче