Skip to content

Commit

Permalink
fix DWARF parsing leaks (#4818)
Browse files Browse the repository at this point in the history
* fix leak in `variable_from_die`
* fix leak in `rz_base_type_clone`
  • Loading branch information
imbillow authored Jan 9, 2025
1 parent 15690c7 commit b196a1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions librz/arch/dwarf_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,12 +1696,14 @@ static bool variable_from_die(
RZ_BORROW RZ_IN RZ_NONNULL DwContext *ctx,
RZ_BORROW RZ_IN RZ_NONNULL const RzBinDwarfDie *die) {
RzAnalysisDwarfVariable v = { 0 };
bool res = false;
if (!function_var_parse(ctx, NULL, NULL, &v, die, NULL)) {
variable_fini(&v);
return false;
goto beach;
}

return try_create_var_global(ctx, die, &v);
res = try_create_var_global(ctx, die, &v);
beach:
variable_fini(&v);
return res;
}

static void die_parse(DwContext *ctx, RzBinDwarfDie *die) {
Expand Down
1 change: 1 addition & 0 deletions librz/type/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ RZ_API RZ_OWN RzBaseType *rz_base_type_clone(RZ_NULLABLE RZ_BORROW RzBaseType *b
return NULL;
}
if (!rz_base_type_clone_into(type, b)) {
rz_type_base_type_free(type);
return NULL;
}
return type;
Expand Down

0 comments on commit b196a1f

Please sign in to comment.