diff --git a/libisofs/builder.c b/libisofs/builder.c index f5ac7ff..38e607a 100644 --- a/libisofs/builder.c +++ b/libisofs/builder.c @@ -20,7 +20,7 @@ #include #include #include - +#include #ifndef PATH_MAX #define PATH_MAX Libisofs_default_path_maX @@ -100,7 +100,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, IsoNode *new; IsoFilesystem *fs; char *name; - unsigned char *aa_string; + unsigned char *aa_string = NULL; char *a_text = NULL, *d_text = NULL; if (builder == NULL || src == NULL || node == NULL) { @@ -217,6 +217,9 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, } iso_aa_get_acl_text(aa_string, info.st_mode, &a_text, &d_text, 1 << 15); /* free ACL texts */ + if(aa_string != NULL) + free(aa_string); + aa_string = NULL; } /* Obtain ownership of eventual AAIP string */ @@ -227,6 +230,8 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string); if (ret < 0) return ret; + } else if(aa_string != NULL) { + free(aa_string); } *node = new; diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 807b2d8..5176d5c 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -620,10 +620,13 @@ void iso_image_remove_boot_image(IsoImage *image) return; /* - * remove catalog node from its parent - * (the reference will be disposed next) + * remove catalog node from its parent and dispose it + * (another reference is with the catalog) */ - iso_node_take((IsoNode*)image->bootcat->node); + if (iso_node_get_parent((IsoNode*) image->bootcat->node) != NULL) { + iso_node_take((IsoNode*) image->bootcat->node); + iso_node_unref((IsoNode*) image->bootcat->node); + } /* free boot catalog and image, including references to nodes */ el_torito_boot_catalog_free(image->bootcat);