Skip to content

Commit

Permalink
Fix memleaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed May 4, 2024
1 parent fe00a87 commit 856cc81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions librz/arch/op.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,7 @@ RZ_API void rz_analysis_insn_word_free(RZ_OWN RZ_NULLABLE RzAnalysisInsnWord *iw
if (!iword) {
return;
}
rz_strbuf_free(iword->asm_str);
rz_pvector_free(iword->insns);
set_u_free(iword->jump_targets);
set_u_free(iword->call_targets);
rz_analysis_insn_word_fini(iword);
free(iword);
}

Expand All @@ -740,5 +737,6 @@ RZ_API void rz_analysis_insn_word_fini(RZ_OWN RZ_NULLABLE RzAnalysisInsnWord *iw
rz_pvector_free(iword->insns);
set_u_free(iword->jump_targets);
set_u_free(iword->call_targets);
rz_il_op_effect_free(iword->il_op);
rz_mem_memzero(iword, sizeof(RzAnalysisInsnWord));
}
5 changes: 4 additions & 1 deletion librz/core/cgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,8 @@ static void extend_icfg(const RzAnalysis *analysis, RZ_BORROW RzGraph /*<RzGraph
RzGraphNode *from_node = get_graph_node_of_fcn(icfg, graph_idx, fcn);
RzListIter *it;
const RzAnalysisXRef *xref;
rz_list_foreach (rz_analysis_function_get_xrefs_from(fcn), it, xref) {
RzList *fcn_xrefs = rz_analysis_function_get_xrefs_from(fcn);
rz_list_foreach (fcn_xrefs, it, xref) {
if (xref->type != RZ_ANALYSIS_XREF_TYPE_CALL) {
continue;
}
Expand All @@ -874,6 +875,7 @@ static void extend_icfg(const RzAnalysis *analysis, RZ_BORROW RzGraph /*<RzGraph
// Recurse into called function.
extend_icfg(analysis, icfg, graph_idx, called_fcn);
}
rz_list_free(fcn_xrefs);
}

/**
Expand Down Expand Up @@ -1343,6 +1345,7 @@ RZ_API RZ_OWN RzGraph /*<RzGraphNodeInfo *>*/ *rz_core_graph_cfg_iwords(RZ_NONNU
return graph;

error:
rz_analysis_insn_word_fini(&cur_iword);
rz_warn_if_reached();
rz_graph_free(graph);
graph = NULL;
Expand Down

0 comments on commit 856cc81

Please sign in to comment.