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.

33 lines
851 B

  1. From 9214f2a4002bafef73c9593464ab3841ba7bac12 Mon Sep 17 00:00:00 2001
  2. From: Michael Heimpold <michael.heimpold@i2se.com>
  3. Date: Tue, 18 Dec 2018 14:49:37 +0100
  4. Subject: [PATCH 2/9] Cleanup memory in error case
  5. In case that we leave due to malformed string,
  6. free the allocated memory before returning.
  7. Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
  8. Cc: Michael Heimpold <mhei@heimpold.de>
  9. ---
  10. lsmmc.c | 4 +++-
  11. 1 file changed, 3 insertions(+), 1 deletion(-)
  12. diff --git a/lsmmc.c b/lsmmc.c
  13. index e514c83..a53bc57 100644
  14. --- a/lsmmc.c
  15. +++ b/lsmmc.c
  16. @@ -378,8 +378,10 @@ char *to_binstr(char *hexstr)
  17. return NULL;
  18. while (hexstr && *hexstr != '\0') {
  19. - if (!isxdigit(*hexstr))
  20. + if (!isxdigit(*hexstr)) {
  21. + free(binstr);
  22. return NULL;
  23. + }
  24. if (isdigit(*hexstr))
  25. strcat(binstr, bindigits[*hexstr - '0']);
  26. --
  27. 2.17.1