Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/inflate: fix memory leak in inflate_dynamic() on inflate_codes() failure

When inflate_codes() fails in inflate_dynamic(), the code jumps to the
'out' label which only frees 'll', leaking the Huffman tables 'tl' and
'td'. Restructure the code so that the decoding tables are always freed
before reaching the 'out' label.

Link: https://lkml.kernel.org/r/20260306161647.2811874-1-objecting@objecting.org
Signed-off-by: Josh Law <objecting@objecting.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Josh Law and committed by
Andrew Morton
84f24da3 bc6cc368

+3 -4
+3 -4
lib/inflate.c
··· 1009 1009 DEBG("dyn6 "); 1010 1010 1011 1011 /* decompress until an end-of-block code */ 1012 - if (inflate_codes(tl, td, bl, bd)) { 1012 + if (inflate_codes(tl, td, bl, bd)) 1013 1013 ret = 1; 1014 - goto out; 1015 - } 1014 + else 1015 + ret = 0; 1016 1016 1017 1017 DEBG("dyn7 "); 1018 1018 ··· 1021 1021 huft_free(td); 1022 1022 1023 1023 DEBG(">"); 1024 - ret = 0; 1025 1024 out: 1026 1025 free(ll); 1027 1026 return ret;