diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 3a23a47a99..3c1a5ea89b 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -478,7 +478,16 @@ struct r_bin_elf_lib_t* Elf_(r_bin_elf_get_libs)(struct Elf_(r_bin_elf_obj_t) *b ret[k].last = 0; k++; } - ret[k].last = 1; + + if (k) { + ret = realloc (ret, (k+1) * sizeof(struct r_bin_elf_lib_t)); + if (ret == NULL) { + perror ("realloc (libs)"); + free (dyn); + return NULL; + } + ret[k].last = 1; + } free (dyn); break; }