| From: Vishnu Sanal T <t.v.s10123@gmail.com> |
| Subject: lib/decompress_unxz.c: fix: possible memory leak in unxz() |
| Date: Sun, 6 Oct 2024 12:55:43 +0530 |
| |
| Fix possible memory leak in the function unxz() in lib/decompress_unxz.c |
| forgets to free the pointer 'in', when the statement if (fill == NULL && |
| flush == NULL) is true. |
| |
| Link: https://lkml.kernel.org/r/20241006072542.66442-2-t.v.s10123@gmail.com |
| Signed-off-by: Vishnu Sanal T <t.v.s10123@gmail.com> |
| Cc: Lasse Collin <lasse.collin@tukaani.org> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| lib/decompress_unxz.c | 6 +++--- |
| 1 file changed, 3 insertions(+), 3 deletions(-) |
| |
| --- a/lib/decompress_unxz.c~fix-possible-memory-leak-in-unxz |
| +++ a/lib/decompress_unxz.c |
| @@ -343,13 +343,13 @@ STATIC int INIT unxz(unsigned char *in, |
| } |
| } while (ret == XZ_OK); |
| |
| - if (must_free_in) |
| - free(in); |
| - |
| if (flush != NULL) |
| free(b.out); |
| } |
| |
| + if (must_free_in) |
| + free(in); |
| + |
| if (in_used != NULL) |
| *in_used += b.in_pos; |
| |
| _ |