Closed a potential memory leak in case of memory shortage

This commit is contained in:
Thomas Schmitt 2012-06-15 20:07:30 +02:00
parent 4d10b8c73c
commit 6fd859a2c1

View File

@ -112,7 +112,12 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
} else { } else {
fsrc->nsections = 1; 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->sort_weight = file->sort_weight;
fsrc->stream = file->stream; fsrc->stream = file->stream;