Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions librz/core/agraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions librz/util/float/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 3 additions & 0 deletions librz/util/itv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions test/integration/test_bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 5 additions & 4 deletions test/unit/test_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_marks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/test_serialize_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 8 additions & 6 deletions test/unit/test_tokens.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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];
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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];
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -789,18 +791,18 @@ 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]);
snprintf(err_msg, sizeof(err_msg), "Colors of \"%s\" are incorrect. Should be \"%s\"\n.", rz_strbuf_get(colored_asm), rz_strbuf_get(expected));
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);
Expand Down
Loading