Commit de27fd97 authored by Michael Heimpold's avatar Michael Heimpold Committed by Chris Ball
Browse files

Cleanup memory in error case



In case that we leave due to malformed string,
free the allocated memory before returning.
Signed-off-by: default avatarMichael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent de0715d5
......@@ -378,8 +378,10 @@ char *to_binstr(char *hexstr)
return NULL;
while (hexstr && *hexstr != '\0') {
if (!isxdigit(*hexstr))
if (!isxdigit(*hexstr)) {
free(binstr);
return NULL;
}
if (isdigit(*hexstr))
strcat(binstr, bindigits[*hexstr - '0']);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment