aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Heimpold <michael.heimpold@i2se.com>2018-12-18 14:47:16 +0100
committerChris Ball <chris@printf.net>2019-10-04 20:47:11 -0400
commitde0715d5b06560904b45633cc6e01fe89d9f508b (patch)
tree17e4fbac885394029e4a3a314d3456d4b6d8dbbc
parentd40ec535b9d4e4c974e8c2fbfb422cd0348cc5e8 (diff)
downloadmmc-utils-de0715d5b06560904b45633cc6e01fe89d9f508b.tar.gz
Check calloc's return value before using the pointer
If calloc fails, bail out immediately instead of trying to use the NULL pointer. Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com> Cc: Michael Heimpold <mhei@heimpold.de> Reviewed-by: Avri Altman <avri.altman@wdc.com> Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r--lsmmc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lsmmc.c b/lsmmc.c
index 9737b37..e514c83 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -374,6 +374,8 @@ char *to_binstr(char *hexstr)
char *binstr;
binstr = calloc(strlen(hexstr) * 4 + 1, sizeof(char));
+ if (!binstr)
+ return NULL;
while (hexstr && *hexstr != '\0') {
if (!isxdigit(*hexstr))