Skip to content

Commit

Permalink
Resolve more memory leaks in the ELF parser
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jan 15, 2025
1 parent 5ecb2db commit 2a74bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libr/bin/bobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ static void object_delete_items(RBinObject *o) {
r_list_free (o->strings);
ht_up_free (o->strings_db);

if (!RVecRBinImport_empty (&o->imports_vec)) {
RVecRBinImport_fini (&o->imports_vec);
}
if (!RVecRBinSymbol_empty (&o->symbols_vec)) {
RVecRBinSymbol_fini (&o->symbols_vec);
if (o->symbols) {
Expand Down Expand Up @@ -422,12 +425,12 @@ R_API int r_bin_object_set_items(RBinFile *bf, RBinObject *bo) {
}
if (bin->filter_rules & (R_BIN_REQ_RELOCS | R_BIN_REQ_IMPORTS)) {
if (p->relocs) {
const RList *l = p->relocs (bf); // XXX this is an internal list (should be a vector), and shouldnt be freed by the caller
RList *l = (RList *)p->relocs (bf); // XXX this is an internal list (should be a vector), and shouldnt be freed by the caller
if (l) {
REBASE_PADDR (bo, l, RBinReloc);
bo->relocs = list2rbtree ((RList*)l);
// l->free = NULL;
// r_list_free (l);
l->free = NULL;
r_list_free (l);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions libr/bin/p/bin_elf.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static void destroy(RBinFile *bf) {
eo->imports_by_ord[i] = NULL;
}
}
eo->imports_by_ord_size = 0;
R_FREE (eo->imports_by_ord);
}
RVecRBinElfSymbol_free (eo->phdr_imports_vec);
Expand Down

0 comments on commit 2a74bad

Please sign in to comment.