From de3e21629f73eb8f996949d26ded230bd99171b8 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 24 Feb 2011 20:02:56 +0100 Subject: [PATCH] Corrected little flaws detected by George Danchev with cpp. --- libisofs/fs_image.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 6e737c0..0375c62 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -3234,6 +3234,8 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, size_t size; void *ctx = NULL; char md5[16]; + struct el_torito_boot_catalog *catalog = NULL; + ElToritoBootImage *boot_image = NULL; if (image == NULL || src == NULL || opts == NULL) { return ISO_NULL_POINTER; @@ -3321,8 +3323,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, /* if old image has el-torito, add a new catalog */ if (data->eltorito) { - struct el_torito_boot_catalog *catalog; - ElToritoBootImage *boot_image= NULL; catalog = calloc(1, sizeof(struct el_torito_boot_catalog)); if (catalog == NULL) { @@ -3348,11 +3348,13 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, memcpy(boot_image->selection_crit, data->selection_crits, 20); catalog->bootimages[catalog->num_bootimages] = boot_image; + boot_image = NULL; catalog->num_bootimages++; } for ( ; idx < Libisofs_max_boot_imageS; idx++) catalog->bootimages[idx] = NULL; image->bootcat = catalog; + catalog = NULL; /* So it does not get freed */ } /* recursively add image */ @@ -3531,6 +3533,10 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, image->fs = fsback; image->builder = blback; + if (catalog != NULL) + el_torito_boot_catalog_free(catalog); + if (boot_image != NULL) + free((char *) boot_image); iso_file_source_unref(newroot); fs->close(fs); iso_filesystem_unref(fs);