diff --git a/librz/core/agraph.c b/librz/core/agraph.c index c11a967104f..a9da9236b20 100644 --- a/librz/core/agraph.c +++ b/librz/core/agraph.c @@ -2356,12 +2356,14 @@ static void fix_back_edge_dummy_nodes(RzAGraph *g, RzANode *from, RzANode *to) { if (tmp) { tmp = v; + agraph_del_graph_edge(g, to->gnode, tmp->gnode); while (tmp->gnode->hash_id != from->gnode->hash_id) { v = tmp; tmp = get_anode(agraph_nth_neighbour(g, tmp->gnode, 0, true)); if (!tmp) { break; } + agraph_del_graph_edge(g, v->gnode, tmp->gnode); i = 0; while (i < g->layers[v->layer].n_nodes && @@ -2834,6 +2836,7 @@ static void set_layout(RzAGraph *g) { free(g->layers); rz_list_free(g->long_edges); rz_list_free(g->back_edges); + // rz_list_free(g->dummy_nodes); rz_cons_break_pop(); } diff --git a/librz/util/float/float.c b/librz/util/float/float.c index af01b4bc307..6c30bfc04ef 100644 --- a/librz/util/float/float.c +++ b/librz/util/float/float.c @@ -1342,6 +1342,7 @@ RZ_API RZ_OWN RzFloat *rz_float_mod_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNUL } rz_float_free(ret); + rz_float_free(right_abs); ret = same_sign; } } diff --git a/librz/util/itv.c b/librz/util/itv.c index 2a424186398..c981150ea2a 100644 --- a/librz/util/itv.c +++ b/librz/util/itv.c @@ -46,11 +46,14 @@ RZ_API bool rz_itv_str_to_bounded_itv_ut64(RZ_NONNULL const char *itv_str, RZ_OU if (num == 0 && itv_str[0] != '0') { RZ_LOG_ERROR("Failed to parse: '%s'.\n", itv_str); rz_pvector_free(matches); + rz_regex_free(re_interval); return false; } out_itv->a = num; out_itv->b = num; out_itv->bound = RZ_INTERVAL_BOUND_CLOSED; + rz_pvector_free(matches); + rz_regex_free(re_interval); return true; } int lb_group = rz_regex_get_group_idx_by_name(re_interval, "left_bound"); diff --git a/test/integration/test_bin.c b/test/integration/test_bin.c index 0f41b6ca247..b183f8183a9 100644 --- a/test/integration/test_bin.c +++ b/test/integration/test_bin.c @@ -171,6 +171,10 @@ bool test_rz_bin_reloc_storage(void) { mu_assert_null(r, "reloc to"); rz_bin_reloc_storage_free(relocs); + rz_bin_reloc_free(r0); + rz_bin_reloc_free(r1); + rz_bin_reloc_free(rz); + rz_bin_reloc_free(r3); mu_end; } diff --git a/test/unit/test_cmd.c b/test/unit/test_cmd.c index 13a871dfc86..3383e0074f6 100644 --- a/test/unit/test_cmd.c +++ b/test/unit/test_cmd.c @@ -216,7 +216,7 @@ bool test_cmd_get_desc(void) { RzCmdDesc *a_cd = rz_cmd_desc_group_new(cmd, root, "a", NULL, NULL, &fake_help); RzCmdDesc *ap_cd = rz_cmd_desc_group_new(cmd, a_cd, "ap", ap_handler, NULL, &fake_help); RzCmdDesc *apd_cd = rz_cmd_desc_argv_new(cmd, ap_cd, "apd", ap_handler, &fake_help); - RzCmdDesc *ae_cd = rz_cmd_desc_argv_new(cmd, a_cd, "ae", ae_handler, &fake_help); + RzCmdDesc *ae_cd = rz_cmd_desc_group_new(cmd, a_cd, "ae", ae_handler, NULL, &fake_help); RzCmdDesc *aeir_cd = rz_cmd_desc_argv_new(cmd, ae_cd, "aeir", aeir_handler, &fake_help); rz_cmd_desc_argv_new(cmd, root, "w", w_handler, &fake_help); @@ -1292,7 +1292,7 @@ bool test_get_best_match(void) { RzCmdDesc *a_cd = rz_cmd_desc_group_new(cmd, root, "a", NULL, NULL, &fake_help); RzCmdDesc *ap_cd = rz_cmd_desc_group_new(cmd, a_cd, "ap", ap_handler, NULL, &fake_help); RzCmdDesc *apd_cd = rz_cmd_desc_argv_new(cmd, ap_cd, "apd", ap_handler, &fake_help); - RzCmdDesc *ae_cd = rz_cmd_desc_argv_new(cmd, a_cd, "ae", ae_handler, &fake_help); + RzCmdDesc *ae_cd = rz_cmd_desc_group_new(cmd, a_cd, "ae", ae_handler, NULL, &fake_help); rz_cmd_desc_argv_new(cmd, ae_cd, "aeir", aeir_handler, &fake_help); rz_cmd_desc_argv_new(cmd, root, "w", w_handler, &fake_help); @@ -1401,7 +1401,7 @@ bool test_call_macros(void) { } bool test_call_multiple_macros(void) { - RzCore *core = RZ_NEW0(RzCore); + RzCore *core = rz_core_new(); core->cons = rz_cons_singleton(); RzCmd *cmd = rz_core_cmd_new(core, false); core->rcmd = cmd; @@ -1426,7 +1426,8 @@ bool test_call_multiple_macros(void) { mu_assert_eq(status, RZ_CMD_STATUS_OK, "macro2 has been called correctly"); status = rz_cmd_macro_call(cmd, "macro2", macro_args_val_wrong); mu_assert_eq(status, RZ_CMD_STATUS_INVALID, "macro2 should be called with a multiple of arguments"); - rz_cmd_free(cmd); + // rz_cmd_free(cmd); + rz_core_free(core); mu_end; } diff --git a/test/unit/test_marks.c b/test/unit/test_marks.c index 05d86ab2b27..aefea032fa2 100644 --- a/test/unit/test_marks.c +++ b/test/unit/test_marks.c @@ -47,6 +47,7 @@ bool test_rz_mark_get_all_off() { mu_assert_eq(found, 2, "both overlapping items found"); rz_mark_free(mark); + rz_list_free(list); mu_end; } @@ -61,6 +62,7 @@ bool test_rz_mark_all_list() { mu_assert_eq(rz_list_length(all), 3, "all marks listed"); rz_mark_free(mark); + rz_list_free(all); mu_end; } diff --git a/test/unit/test_regex.c b/test/unit/test_regex.c index 066478989ea..584227e0884 100644 --- a/test/unit/test_regex.c +++ b/test/unit/test_regex.c @@ -331,7 +331,7 @@ bool test_rz_regex_match_all_native_utf16(void) { mu_assert_eq(match->len, 4, "match.len wrong"); rz_pvector_free(matches); - + rz_mem_free(utf16_he); rz_regex_free(re); mu_end; } @@ -394,7 +394,7 @@ bool test_rz_regex_match_all_native_utf32(void) { mu_assert_eq(match->len, 3, "match.len wrong"); rz_pvector_free(matches); - + rz_mem_free(utf32_he); rz_regex_free(re); mu_end; } diff --git a/test/unit/test_serialize_types.c b/test/unit/test_serialize_types.c index f284740958d..9026f19b60d 100644 --- a/test/unit/test_serialize_types.c +++ b/test/unit/test_serialize_types.c @@ -39,11 +39,13 @@ Sdb *types_ref_db() { } bool sdb_has_record(Sdb *db, const char *key, const char *value) { - const char *result = sdb_get(db, key); + char *result = sdb_get(db, key); if (!result) { return false; } - return !strcmp(result, value); + bool ret = !strcmp(result, value); + rz_mem_free(result); + return ret; } bool test_types_save() { diff --git a/test/unit/test_tokens.c b/test/unit/test_tokens.c index 9a4b7909200..07fed271281 100644 --- a/test/unit/test_tokens.c +++ b/test/unit/test_tokens.c @@ -374,6 +374,7 @@ static bool test_rz_tokenize_custom_hexagon_issues_tilde(void) { mu_assert_eq(tok->val.number, 0, "Token value"); rz_asm_op_fini(op); + rz_asm_op_free(op); rz_asm_free(a); mu_end; } @@ -399,6 +400,7 @@ static bool test_rz_tokenize_custom_hexagon_issues_long_reg(void) { mu_assert_eq(tok->val.number, 0, "Token value"); rz_asm_op_fini(op); + rz_asm_op_free(op); rz_asm_free(a); mu_end; } @@ -678,7 +680,6 @@ static bool test_rz_colorize_custom_hexagon_2(void) { rz_asm_set_utf8(d, true); RzPrint *p = setup_print(); - RzAsmOp asmop = { 0 }; RzStrBuf *colored_asm; RzStrBuf *expected; char err_msg[2048]; @@ -697,6 +698,7 @@ static bool test_rz_colorize_custom_hexagon_2(void) { }; for (int i = 0; i < 0x14; i += 4) { + RzAsmOp asmop = { 0 }; rz_asm_set_pc(d, i); rz_asm_disassemble(d, &asmop, buf + i, 4); colored_asm = rz_print_colorize_asm_str(p, asmop.asm_toks); @@ -705,9 +707,9 @@ static bool test_rz_colorize_custom_hexagon_2(void) { mu_assert_true(rz_strbuf_equals(colored_asm, expected), err_msg); rz_strbuf_free(colored_asm); rz_strbuf_free(expected); + rz_asm_op_fini(&asmop); } - rz_asm_op_fini(&asmop); rz_asm_free(d); rz_cons_context_free(p->cons->context); rz_print_free(p); @@ -719,7 +721,6 @@ static bool test_rz_colorize_custom_hexagon_3(void) { rz_asm_set_utf8(d, true); RzPrint *p = setup_print(); - RzAsmOp asmop = { 0 }; RzStrBuf *colored_asm; RzStrBuf *expected; char err_msg[2048]; @@ -741,6 +742,7 @@ static bool test_rz_colorize_custom_hexagon_3(void) { }; for (int i = 0; i < 0x10; i += 4) { + RzAsmOp asmop = { 0 }; rz_asm_set_pc(d, i); rz_asm_disassemble(d, &asmop, buf + i, 0x10 - i); @@ -750,9 +752,9 @@ static bool test_rz_colorize_custom_hexagon_3(void) { mu_assert_true(rz_strbuf_equals(colored_asm, expected), err_msg); rz_strbuf_free(colored_asm); rz_strbuf_free(expected); + rz_asm_op_fini(&asmop); } - rz_asm_op_fini(&asmop); rz_cons_context_free(p->cons->context); rz_print_free(p); rz_asm_free(d); @@ -789,8 +791,8 @@ static bool test_rz_tokenize_custom_bf_0(void) { RzPrint *p = setup_print(); char err_msg[2048]; - RzAsmOp asmop = { 0 }; for (int i = 0; i < sizeof(buf) - 1; i++) { + RzAsmOp asmop = { 0 }; rz_asm_disassemble(a, &asmop, buf + i, 1); RzStrBuf *colored_asm = rz_print_colorize_asm_str(p, asmop.asm_toks); RzStrBuf *expected = rz_strbuf_new(expected_str[i]); @@ -798,9 +800,9 @@ static bool test_rz_tokenize_custom_bf_0(void) { mu_assert_true(rz_strbuf_equals(colored_asm, expected), err_msg); rz_strbuf_free(expected); rz_strbuf_free(colored_asm); + rz_asm_op_fini(&asmop); } - rz_asm_op_fini(&asmop); rz_asm_free(a); rz_cons_context_free(p->cons->context); rz_print_free(p);