Handle propertly root dir, that hasn't name nor parent.

This commit is contained in:
Vreixo Formoso 2008-01-01 20:27:52 +01:00
parent 34e7a8dad0
commit 8423e0acf6
1 changed files with 6 additions and 5 deletions

View File

@ -176,7 +176,7 @@ char* ifs_get_name(IsoFileSource *src)
{ {
ImageFileSourceData *data; ImageFileSourceData *data;
data = src->data; data = src->data;
return strdup(data->name); return data->name == NULL ? NULL : strdup(data->name);
} }
static static
@ -272,7 +272,9 @@ void ifs_free(IsoFileSource *src)
free(data->data.content); free(data->data.content);
} }
iso_filesystem_unref((IsoFilesystem*)data->fs); iso_filesystem_unref((IsoFilesystem*)data->fs);
iso_file_source_unref(data->parent); if (data->parent != NULL) {
iso_file_source_unref(data->parent);
}
free(data->name); free(data->name);
free(data); free(data);
} }
@ -320,8 +322,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
uint32_t relocated_dir = 0; uint32_t relocated_dir = 0;
if (fs == NULL || fs->fs.data == NULL || parent == NULL || record == NULL if (fs == NULL || fs->fs.data == NULL || record == NULL || src == NULL) {
|| src == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
@ -591,7 +592,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* fill data */ /* fill data */
ifsdata->fs = fs; ifsdata->fs = fs;
iso_filesystem_ref((IsoFilesystem*)fs); iso_filesystem_ref((IsoFilesystem*)fs);
if (parent) { if (parent != NULL) {
ifsdata->parent = parent; ifsdata->parent = parent;
iso_file_source_ref(parent); iso_file_source_ref(parent);
} }