From 6fd859a2c1f6b422afa26b78aa7d6711d2930a4f Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 15 Jun 2012 20:07:30 +0200 Subject: [PATCH] Closed a potential memory leak in case of memory shortage --- libisofs/filesrc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libisofs/filesrc.c b/libisofs/filesrc.c index 42d87ee..d79e25d 100644 --- a/libisofs/filesrc.c +++ b/libisofs/filesrc.c @@ -112,7 +112,12 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src) } else { fsrc->nsections = 1; } - fsrc->sections = calloc(fsrc->nsections, sizeof(struct iso_file_section)); + fsrc->sections = calloc(fsrc->nsections, + sizeof(struct iso_file_section)); + if (fsrc->sections == NULL) { + free(fsrc); + return ISO_OUT_OF_MEM; + } } fsrc->sort_weight = file->sort_weight; fsrc->stream = file->stream;