From 8423e0acf662f7b4e2a9248acff34066c5f4f903 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Tue, 1 Jan 2008 20:27:52 +0100 Subject: [PATCH] Handle propertly root dir, that hasn't name nor parent. --- src/fs_image.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fs_image.c b/src/fs_image.c index b23f537..c5d04c6 100644 --- a/src/fs_image.c +++ b/src/fs_image.c @@ -176,7 +176,7 @@ char* ifs_get_name(IsoFileSource *src) { ImageFileSourceData *data; data = src->data; - return strdup(data->name); + return data->name == NULL ? NULL : strdup(data->name); } static @@ -272,7 +272,9 @@ void ifs_free(IsoFileSource *src) free(data->data.content); } 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); } @@ -320,8 +322,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent, uint32_t relocated_dir = 0; - if (fs == NULL || fs->fs.data == NULL || parent == NULL || record == NULL - || src == NULL) { + if (fs == NULL || fs->fs.data == NULL || record == NULL || src == NULL) { return ISO_NULL_POINTER; } @@ -591,7 +592,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent, /* fill data */ ifsdata->fs = fs; iso_filesystem_ref((IsoFilesystem*)fs); - if (parent) { + if (parent != NULL) { ifsdata->parent = parent; iso_file_source_ref(parent); }