From 5ac3216933983821411169f3e1929583e933a757 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 10 Oct 2015 13:11:31 +0200 Subject: [PATCH] Closed memory leak with lack of memory during retrieval of HFS+ names. Coverity CID 12580. --- libisofs/hfsplus.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libisofs/hfsplus.c b/libisofs/hfsplus.c index 195952f..f4aa880 100644 --- a/libisofs/hfsplus.c +++ b/libisofs/hfsplus.c @@ -137,8 +137,10 @@ int iso_get_hfsplus_name(char *input_charset, int imgid, char *name, curlen = ucslen (ucs_name); *result = calloc ((curlen * HFSPLUS_MAX_DECOMPOSE_LEN + 1), sizeof (uint16_t)); - if (*result == NULL) + if (*result == NULL) { + free(ucs_name); return ISO_OUT_OF_MEM; + } for (iptr = ucs_name, optr = *result; *iptr; iptr++) { @@ -208,8 +210,12 @@ int iso_get_hfsplus_name(char *input_charset, int imgid, char *name, while (done); *cmp_name = calloc ((ucslen (*result) + 1), sizeof (uint16_t)); - if (*cmp_name == NULL) - return ISO_OUT_OF_MEM; + if (*cmp_name == NULL) { + free(ucs_name); + free(*result); + *result = NULL; + return ISO_OUT_OF_MEM; + } for (iptr = *result, optr = *cmp_name; *iptr; iptr++) {