Message ID | 20181016203043.26932-1-valentin.ilie@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mmc-utils: Fix memory leak | expand |
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']);
Free binstr when returning NULL. Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com> --- lsmmc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)