Skip to content

Commit

Permalink
Fix memleak in rz_bin_string_database_new() (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah committed Mar 6, 2024
1 parent d3c05ca commit 6e81378
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions librz/bin/bobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,22 +976,16 @@ RZ_API RZ_OWN RzBinStrDb *rz_bin_string_database_new(RZ_NULLABLE RZ_OWN RzPVecto
return NULL;
}

void **it;
RzBinString *bstr;
db->pvec = rz_pvector_new((RzPVectorFree)rz_bin_string_free);
if (pvector) {
rz_pvector_foreach (pvector, it) {
bstr = *it;
rz_pvector_push(db->pvec, bstr);
}
}
db->pvec = pvector ? pvector : rz_pvector_new((RzPVectorFree)rz_bin_string_free);
db->phys = ht_up_new0();
db->virt = ht_up_new0();
if (!db->pvec || !db->phys || !db->virt) {
RZ_LOG_ERROR("rz_bin: Cannot allocate RzBinStrDb internal data structure.\n");
goto fail;
}

void **it;
RzBinString *bstr;
rz_pvector_foreach (pvector, it) {
bstr = *it;
if (!ht_up_update(db->phys, bstr->paddr, bstr)) {
Expand Down

0 comments on commit 6e81378

Please sign in to comment.