From 9538a5d57bd3a137a8658625234386584f928c69 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 28 Apr 2011 20:24:17 +0200 Subject: [PATCH] Performing collision test before FileSource creation in iso_tree_add_new_node() --- libisofs/tree.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libisofs/tree.c b/libisofs/tree.c index 7b345fe..655e180 100644 --- a/libisofs/tree.c +++ b/libisofs/tree.c @@ -574,20 +574,19 @@ int iso_tree_add_new_node(IsoImage *image, IsoDir *parent, const char *name, *node = NULL; } - fs = image->fs; - result = fs->get_by_path(fs, path, &file); - if (result < 0) { - return result; - } - /* find place where to insert */ result = iso_dir_exists(parent, name, &pos); if (result) { /* a node with same name already exists */ - iso_file_source_unref(file); return ISO_NODE_NAME_NOT_UNIQUE; } + fs = image->fs; + result = fs->get_by_path(fs, path, &file); + if (result < 0) { + return result; + } + result = image->builder->create_node(image->builder, image, file, &new); /* free the file */