From 8c1c0775d6472e9015b1aa09fb1c3629b7ee57f1 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 13 Apr 2014 11:07:10 +0200 Subject: [PATCH] Closed a memory leak with loading of hidden boot images --- libisofs/fs_image.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 806d9a1..220c32c 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -5324,11 +5324,21 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, } ret = image_builder_create_node(image->builder, image, boot_src, NULL, &node); + iso_file_source_unref(boot_src); /* Now owned by node */ if (ret < 0) { iso_node_builder_unref(image->builder); goto import_revert; } - image->bootcat->bootimages[idx]->image = (IsoFile*)node; + if (image->bootcat->bootimages[idx]->image != NULL) { + /* Already added to bootimages in image_builder_create_node(). + * Now it has one refcount for tree and one for bootimages. + * But it will not go to tree. So unref. + */ + iso_node_unref(node); + } else { + image->bootcat->bootimages[idx]->image = (IsoFile*)node; + } + /* warn about hidden images */ iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0,