Bug fix: Prevent allocation of empty ECMA-119 directory children list.
Thanks Richard Nolde.
This commit is contained in:
parent
0e00aeb638
commit
185cbd99bf
@ -201,22 +201,25 @@ static
|
||||
int create_dir(Ecma119Image *img, IsoDir *iso, Ecma119Node **node)
|
||||
{
|
||||
int ret;
|
||||
Ecma119Node **children;
|
||||
Ecma119Node **children = NULL;
|
||||
struct ecma119_dir_info *dir_info;
|
||||
|
||||
if (iso->nchildren > 0) {
|
||||
children = calloc(1, sizeof(void*) * iso->nchildren);
|
||||
if (children == NULL) {
|
||||
if (children == NULL)
|
||||
return ISO_OUT_OF_MEM;
|
||||
}
|
||||
|
||||
dir_info = calloc(1, sizeof(struct ecma119_dir_info));
|
||||
if (dir_info == NULL) {
|
||||
if (children != NULL)
|
||||
free(children);
|
||||
return ISO_OUT_OF_MEM;
|
||||
}
|
||||
|
||||
ret = create_ecma119_node(img, (IsoNode*)iso, node);
|
||||
if (ret < 0) {
|
||||
if (children != NULL)
|
||||
free(children);
|
||||
free(dir_info);
|
||||
return ret;
|
||||
@ -353,6 +356,7 @@ void ecma119_node_free(Ecma119Node *node)
|
||||
for (i = 0; i < node->info.dir->nchildren; i++) {
|
||||
ecma119_node_free(node->info.dir->children[i]);
|
||||
}
|
||||
if (node->info.dir->children != NULL)
|
||||
free(node->info.dir->children);
|
||||
free(node->info.dir);
|
||||
}
|
||||
@ -564,6 +568,8 @@ void sort_tree(Ecma119Node *root)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (root->info.dir->children == NULL)
|
||||
return;
|
||||
qsort(root->info.dir->children, root->info.dir->nchildren, sizeof(void*),
|
||||
cmp_node_name);
|
||||
for (i = 0; i < root->info.dir->nchildren; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user