You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
795 B

  1. From bf96e1b2f48eab26c4a0c2a0903d9d7b9a311a1d Mon Sep 17 00:00:00 2001
  2. From: Michael Heimpold <michael.heimpold@i2se.com>
  3. Date: Tue, 18 Dec 2018 14:47:16 +0100
  4. Subject: [PATCH 1/9] Check calloc's return value before using the pointer
  5. If calloc fails, bail out immediately instead of trying to
  6. use the NULL pointer.
  7. Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
  8. Cc: Michael Heimpold <mhei@heimpold.de>
  9. ---
  10. lsmmc.c | 2 ++
  11. 1 file changed, 2 insertions(+)
  12. diff --git a/lsmmc.c b/lsmmc.c
  13. index 9737b37..e514c83 100644
  14. --- a/lsmmc.c
  15. +++ b/lsmmc.c
  16. @@ -374,6 +374,8 @@ char *to_binstr(char *hexstr)
  17. char *binstr;
  18. binstr = calloc(strlen(hexstr) * 4 + 1, sizeof(char));
  19. + if (!binstr)
  20. + return NULL;
  21. while (hexstr && *hexstr != '\0') {
  22. if (!isxdigit(*hexstr))
  23. --
  24. 2.17.1