X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=src%2Fmodel%2FfromFile.c;h=57cb51971bb84016e08ad07202b23a0657330db9;hb=f5eac562c915811c27969949c178f8fe96a12e47;hp=fee6ec03fabd4cc08ddef6572757c42d821c7bed;hpb=3d899fbfd33a8b44dcbd7dfbc952464731a7e589;p=centaur.git diff --git a/src/model/fromFile.c b/src/model/fromFile.c index fee6ec0..57cb519 100644 --- a/src/model/fromFile.c +++ b/src/model/fromFile.c @@ -94,6 +94,12 @@ ElfuElf* elfu_mFromElf(Elf *e) size_t shstrndx; size_t i, n; + assert(e); + if (elfu_eCheck(e)) { + goto ERROR; + } + + /* Get the section string table index */ if (elf_getshdrstrndx(e, &shstrndx) != 0) { shstrndx = 0; } @@ -117,7 +123,7 @@ ElfuElf* elfu_mFromElf(Elf *e) if (!gelf_getehdr(e, &me->ehdr)) { ELFU_WARNELF("gelf_getehdr"); - goto out; + goto ERROR; } @@ -135,7 +141,7 @@ ElfuElf* elfu_mFromElf(Elf *e) me->shstrtab = ms; } } else { - goto out; + goto ERROR; } scn = elf_nextscn(e, scn); @@ -165,15 +171,16 @@ ElfuElf* elfu_mFromElf(Elf *e) if (mp) { CIRCLEQ_INSERT_TAIL(&me->phdrList, mp, elem); } else { - goto out; + goto ERROR; } } + return me; - return me; + ERROR: + // TODO: Free data structures - out: - // FIXME + ELFU_WARN("elfu_mFromElf: Failed to load file.\n"); return NULL; }