diff --git a/librz/bin/p/bin_hunk.c b/librz/bin/p/bin_hunk.c index 86c2709c02..b5576f4a72 100644 --- a/librz/bin/p/bin_hunk.c +++ b/librz/bin/p/bin_hunk.c @@ -491,8 +491,10 @@ static RzPVector /**/ *hunk_sections(RzBinFile *bf) { char *section_name = rz_str_newf("hunk_%d_%s", i, hunk_get_name_from_type(hunk_data->type)); RzBinSection *section = rz_bin_section_new(section_name); + free(section_name); if (!section) { - return false; + rz_pvector_free(ret); + return NULL; } rz_pvector_push(ret, section); @@ -521,17 +523,16 @@ static bool hunk_handle_symbols_for_hunk_data(HunkData *hunk_data, RzPVector /*< if (!hunk_symbol) { continue; } - char *symbol_name = rz_str_dup(hunk_symbol->name); ut64 paddr = hunk_data->paddr + hunk_symbol->offset; ut64 vaddr = hunk_data->vaddr + hunk_symbol->offset; - RzBinSymbol *symbol = rz_bin_symbol_new(symbol_name, paddr, vaddr); + RzBinSymbol *symbol = rz_bin_symbol_new(hunk_symbol->name, paddr, vaddr); if (!symbol) { return false; } rz_pvector_push(ret, symbol); symbol->size = 0; - symbol->type = rz_str_dup(hunk_data->type == HUNK_CODE ? "FUNC" : "OBJ"); + symbol->type = hunk_data->type == HUNK_CODE ? RZ_BIN_TYPE_FUNC_STR : RZ_BIN_TYPE_OBJECT_STR; } return true; } diff --git a/librz/bin/p/bin_smd.c b/librz/bin/p/bin_smd.c index 68db4c72cc..3a62f15291 100644 --- a/librz/bin/p/bin_smd.c +++ b/librz/bin/p/bin_smd.c @@ -245,7 +245,7 @@ static RzPVector /**/ *smd_sections(RzBinFile *bf) { const smd_t *hdr = bf->o->bin_obj; RzPVector *ret = NULL; - if (!(ret = rz_pvector_new(NULL))) { + if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) { return NULL; } RzBinSection *ptr; @@ -300,7 +300,7 @@ static RzPVector /**/ *smd_entries(RzBinFile *bf) { RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_pvector_new(NULL))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } if (!(ptr = RZ_NEW0(RzBinAddr))) {