Skip to contentSkip to conversation

lib: fix potential memory free failure on unlzo()

PATCH New Namhyung Kim 1 participant 1 message Nov 20, 2011 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: fix potential memory free failure on unlzo()

in_buf is dynamically allocated if @input is not given, and adjusted as processing data on every loop. However if block metadata is corrupted it will bail out the loop in the middle, thus in_buf will point out wrong memory. Fix it by freeing in_buf_save instead.

Cc Albin Tonnerre <[email protected]>
Cc Lasse Collin <[email protected]>
---
 lib/decompress_unlzo.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/decompress_unlzo.c +1 -1
index 5a7a2adf4c4c..4531294fa62f 100644
@@ -279,7 +279,7 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,
 	ret = 0;
 exit_2:
 	if (!input)
-		free(in_buf);
+		free(in_buf_save);
 exit_1:
 	if (!output)
 		free(out_buf);

--
1.7.6