From ace0d1ab2eee660d92fc75a9f2af3c80b2b9dff0 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 22 Apr 2010 23:13:54 +0200 Subject: [PATCH] Bug fix of previous revision 653: SIGSEGV because of dereferencing NULL when writing without boot image. --- libisofs/ecma119.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index d2cc8a6..41ce015 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -1167,15 +1167,20 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) /* el-torito? */ target->eltorito = (src->bootcat == NULL ? 0 : 1); target->catalog = src->bootcat; - target->num_bootsrc = target->catalog->num_bootimages; - target->bootsrc = calloc(target->num_bootsrc + 1, - sizeof(IsoFileSrc *)); - if (target->bootsrc == NULL) { - ret = ISO_OUT_OF_MEM; - goto target_cleanup; + if (target->catalog != NULL) { + target->num_bootsrc = target->catalog->num_bootimages; + target->bootsrc = calloc(target->num_bootsrc + 1, + sizeof(IsoFileSrc *)); + if (target->bootsrc == NULL) { + ret = ISO_OUT_OF_MEM; + goto target_cleanup; + } + for (i= 0; i < target->num_bootsrc; i++) + target->bootsrc[i] = NULL; + } else { + target->num_bootsrc = 0; + target->bootsrc = NULL; } - for (i= 0; i < target->num_bootsrc; i++) - target->bootsrc[i] = NULL; if (opts->system_area_data != NULL) { system_area = opts->system_area_data;