From 48453ef1da8e278722d326996fcd66997be7cce3 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 9 Oct 2015 20:07:29 +0200 Subject: [PATCH] Closed memory leaks with errors during ISO image import. Coverity CID 12572. --- libisofs/fs_image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index c273b54..c8836c9 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -5697,21 +5697,26 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, if (image->system_area_data != NULL) free(image->system_area_data); image->system_area_data = calloc(32768, 1); - if (image->system_area_data == NULL) + if (image->system_area_data == NULL) { + iso_filesystem_unref(fs); return ISO_OUT_OF_MEM; + } image->system_area_options = 0; /* Read 32768 bytes */ for (i = 0; i < 16; i++) { rpt = (uint8_t *) (image->system_area_data + i * 2048); ret = src->read_block(src, opts->block + i, rpt); - if (ret < 0) + if (ret < 0) { + iso_filesystem_unref(fs); return ret; + } } } /* get root from filesystem */ ret = fs->get_root(fs, &newroot); if (ret < 0) { + iso_filesystem_unref(fs); return ret; }