Made sure that iso_file_get_old_image_sections() returns non-NULL only

if section_count > 0. Made sure that callers in libisofs expect all possible
outcome as announced by API description.
This commit is contained in:
2015-10-09 12:03:14 +02:00
parent 83fb614462
commit e35cb88328
3 changed files with 14 additions and 9 deletions

View File

@@ -1193,16 +1193,17 @@ int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag)
{
int ret;
int section_count;
struct iso_file_section *sections;
struct iso_file_section *sections = NULL;
if (file == NULL || lba == NULL) {
return ISO_NULL_POINTER;
}
ret = iso_file_get_old_image_sections(file, &section_count, &sections, flag);
if (ret <= 0) {
ret = iso_file_get_old_image_sections(file, &section_count, &sections, 0);
if (ret <= 0)
return ret;
}
if (section_count != 1) {
free(sections);
if (sections != NULL)
free(sections);
return ISO_WRONG_ARG_VALUE;
}
*lba = sections[0].block;
@@ -1211,7 +1212,6 @@ int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag)
}
/*
* Like iso_file_get_old_image_lba(), but take an IsoNode.
*