Fixed a memory fault introduced with rev 1106
This commit is contained in:
parent
d23462657b
commit
5383ae2faa
@ -503,10 +503,10 @@ int iso_tree_add_node_builder(IsoImage *image, IsoDir *parent,
|
|||||||
int result;
|
int result;
|
||||||
IsoNode *new;
|
IsoNode *new;
|
||||||
IsoNode **pos;
|
IsoNode **pos;
|
||||||
char *name;
|
char *name = NULL;
|
||||||
|
|
||||||
if (parent == NULL || src == NULL || builder == NULL) {
|
if (parent == NULL || src == NULL || builder == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
result = ISO_NULL_POINTER; goto ex;
|
||||||
}
|
}
|
||||||
if (node) {
|
if (node) {
|
||||||
*node = NULL;
|
*node = NULL;
|
||||||
@ -516,23 +516,25 @@ int iso_tree_add_node_builder(IsoImage *image, IsoDir *parent,
|
|||||||
|
|
||||||
/* find place where to insert */
|
/* find place where to insert */
|
||||||
result = iso_dir_exists(parent, name, &pos);
|
result = iso_dir_exists(parent, name, &pos);
|
||||||
free(name);
|
|
||||||
if (result) {
|
if (result) {
|
||||||
/* a node with same name already exists */
|
/* a node with same name already exists */
|
||||||
return ISO_NODE_NAME_NOT_UNIQUE;
|
result = ISO_NODE_NAME_NOT_UNIQUE; goto ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = builder->create_node(builder, image, src, name, &new);
|
result = builder->create_node(builder, image, src, name, &new);
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
return result;
|
goto ex;
|
||||||
}
|
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
*node = new;
|
*node = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finally, add node to parent */
|
/* finally, add node to parent */
|
||||||
return iso_dir_insert(parent, (IsoNode*)new, pos, ISO_REPLACE_NEVER);
|
result = iso_dir_insert(parent, (IsoNode*)new, pos, ISO_REPLACE_NEVER);
|
||||||
|
ex:
|
||||||
|
if (name != NULL)
|
||||||
|
free(name);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
|
int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
|
||||||
|
Loading…
Reference in New Issue
Block a user