mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
lib: decompress_unxz: make it obvious that there is no memory leak
Calling __decompress() or unxz() with fill == NULL && flush == NULL && in == NULL is invalid, thus there were no memory leaks even though it might have looked like that. Move the conditional free() calls so that it's obvious that there are no leaks. Link: https://lore.kernel.org/[email protected] Link: https://lore.kernel.org/lkml/[email protected]/T/ Link: https://lore.kernel.org/lkml/[email protected]/T/ Signed-off-by: Ivy Lopez <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=207113 Reviewed-by: Lasse Collin <[email protected]>
This commit is contained in:
@@ -342,14 +342,14 @@ STATIC int INIT unxz(unsigned char *in, long in_size,
|
||||
b.out_pos = 0;
|
||||
}
|
||||
} while (ret == XZ_OK);
|
||||
|
||||
if (must_free_in)
|
||||
free(in);
|
||||
|
||||
if (flush != NULL)
|
||||
free(b.out);
|
||||
}
|
||||
|
||||
if (must_free_in)
|
||||
free(in);
|
||||
|
||||
if (flush != NULL)
|
||||
free(b.out);
|
||||
|
||||
if (in_used != NULL)
|
||||
*in_used += b.in_pos;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user