[PATCH] mmc-utils: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Free binstr when returning NULL.

Signed-off-by: Valentin Ilie <valentin.ilie@xxxxxxxxx>
---
 lsmmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lsmmc.c b/lsmmc.c
index c4faa00..d3ef687 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -370,8 +370,10 @@ char *to_binstr(char *hexstr)
 	binstr = calloc(strlen(hexstr) * 4 + 1, sizeof(char));
 
 	while (hexstr && *hexstr != '\0') {
-		if (!isxdigit(*hexstr))
+		if (!isxdigit(*hexstr)) {
+			free(binstr);
 			return NULL;
+		}
 
 		if (isdigit(*hexstr))
 			strcat(binstr, bindigits[*hexstr - '0']);
-- 
2.17.1




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux