Skip to content

Commit

Permalink
Fix some ELF/Dwarf memleaks reported by Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Apr 29, 2015
1 parent 1c33214 commit 40de063
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions libr/bin/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ static const ut8 *r_bin_dwarf_parse_lnp_header (
char *str = r_str_ndup ((const char *)buf, len);
if (len<1 || len >= 0xfff) {
buf += 1;
free (str);
break;
}
if (f) fprintf (f, "INCLUDEDIR (%s)\n", buf);
Expand Down
8 changes: 6 additions & 2 deletions libr/bin/format/elf/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,14 @@ static int Elf_(r_bin_elf_init_dynamic_section) (struct Elf_(r_bin_elf_obj_t) *b
dyn = (Elf_(Dyn)*)calloc (entries, sizeof (Elf_(Dyn)));
if (!dyn) return R_FALSE;

if (!UT32_MUL (&dyn_size, entries, sizeof (Elf_(Dyn))))
if (!UT32_MUL (&dyn_size, entries, sizeof (Elf_(Dyn)))) {
free (dyn);
return R_FALSE;
if (!dyn_size)
}
if (!dyn_size) {
free (dyn);
return R_FALSE;
}
if (bin->phdr[i].p_offset + dyn_size > bin->size){
free (dyn);
return R_FALSE;
Expand Down

0 comments on commit 40de063

Please sign in to comment.