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