Skip to content

Commit 6544881

Browse files
committed
Fix UAF in aaft (tests_64923) ##crash
Reported by giantbranch of NSFOCUS TIANJI Lab
1 parent 49b0ceb commit 6544881

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

libr/core/anal_tp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,12 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
504504
char prev_type[256] = {0};
505505
const char *prev_dest = NULL;
506506
char *ret_reg = NULL;
507-
const char *pc = r_reg_get_name (core->dbg->reg, R_REG_NAME_PC);
508-
if (!pc) {
509-
free (buf);
507+
const char *_pc = r_reg_get_name (core->dbg->reg, R_REG_NAME_PC);
508+
if (!_pc) {
509+
free (buf);
510510
return;
511511
}
512+
char *pc = strdup (_pc);
512513
RRegItem *r = r_reg_get (core->dbg->reg, pc, -1);
513514
if (!r) {
514515
free (buf);
@@ -778,4 +779,5 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
778779
free (buf);
779780
r_cons_break_pop();
780781
anal_emul_restore (core, hc, dt, et);
782+
free (pc);
781783
}

0 commit comments

Comments
 (0)