Skip to content

Commit

Permalink
Fix leaks in cstest
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Apr 17, 2024
1 parent 069aaa4 commit dab464c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions suite/cstest/src/capstone_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ void test_single_MC(csh *handle, int mc_mode, char *line)
// and laeds to wrong results.
cs_arch arch = ((struct cs_struct *)(uintptr_t)*handle)->arch;
if (arch != CS_ARCH_ARM) {
if (insn->detail) {
free(insn->detail);
}
free(insn);
cs_disasm(*handle, code, size_byte, offset, 0, &insn);

strcpy(tmp_noreg, insn[0].mnemonic);
Expand Down
5 changes: 5 additions & 0 deletions suite/cstest/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ static void test_file(const char *filename)
printf("[!] Noted:\n[ ERROR ] --- \"<capstone result>\" != \"<user result>\"\n");
printf("\n\n");
free_strs(list_lines, size_lines);
for (int k = 0; tests && k < number_of_tests; k++) {
free((char *)tests[k].name);
}
free(tests);
free(content);
}

static void test_folder(const char *folder)
Expand Down

0 comments on commit dab464c

Please sign in to comment.