diff --git a/libr/anal/p/anal_tms320.c b/libr/anal/p/anal_tms320.c index ebff8ef57b..9f91cb3bd1 100644 --- a/libr/anal/p/anal_tms320.c +++ b/libr/anal/p/anal_tms320.c @@ -10,7 +10,7 @@ #include "../../asm/arch/tms320/tms320_dasm.h" -static tms320_dasm_t engine = { }; +static tms320_dasm_t engine = { 0 }; typedef int (* TMS_ANAL_OP_FN)(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len); @@ -18,19 +18,16 @@ int tms320_c54x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) int tms320_c55x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len); int tms320_c55x_plus_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len); -static boolt match(const char * str, const char * token) -{ +static boolt match(const char * str, const char * token) { return !strncasecmp(str, token, strlen(token)); } -int tms320_c54x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) -{ +int tms320_c54x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) { // TODO: add the implementation return 0; } -int tms320_c55x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) -{ +int tms320_c55x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) { const char * str = engine.syntax; op->delay = 0; @@ -80,8 +77,7 @@ int tms320_c55x_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) return op->size; } -int tms320_op(RAnal * anal, RAnalOp * op, ut64 addr, const ut8 * buf, int len) -{ +int tms320_op(RAnal * anal, RAnalOp * op, ut64 addr, const ut8 * buf, int len) { TMS_ANAL_OP_FN aop = tms320_c55x_op; if (anal->cpu && strcasecmp(anal->cpu, "c54x") == 0) @@ -94,14 +90,12 @@ int tms320_op(RAnal * anal, RAnalOp * op, ut64 addr, const ut8 * buf, int len) return aop(anal, op, addr, buf, len); } -static int tms320_init(void * unused) -{ - return tms320_dasm_init(&engine); +static int tms320_init(void * unused) { + return tms320_dasm_init (&engine); } -static int tms320_fini(void * unused) -{ - return tms320_dasm_fini(&engine); +static int tms320_fini(void * unused) { + return tms320_dasm_fini (&engine); } struct r_anal_plugin_t r_anal_plugin_tms320 = { diff --git a/libr/anal/rpnesil.c b/libr/anal/rpnesil.c index d0224c02e1..05c087293e 100644 --- a/libr/anal/rpnesil.c +++ b/libr/anal/rpnesil.c @@ -1019,6 +1019,7 @@ static int esil_deceq (RAnalEsil *esil) { sd--; esil->cur = sd; esil_reg_write (esil, src_dst, sd); +eprintf ("REGWRITE %d\n", sd); ret = R_TRUE; } else { eprintf ("esil_deceq: invalid parameters\n"); diff --git a/libr/asm/arch/tms320/tms320_dasm.c b/libr/asm/arch/tms320/tms320_dasm.c index fd4fd41c2c..6814fa5e64 100644 --- a/libr/asm/arch/tms320/tms320_dasm.c +++ b/libr/asm/arch/tms320/tms320_dasm.c @@ -1099,8 +1099,7 @@ static insn_head_t c55x_list[] = { # include "c55x/table.h" }; -int tms320_dasm_init(tms320_dasm_t * dasm) -{ +int tms320_dasm_init(tms320_dasm_t * dasm) { int i = 0; dasm->map = ht_(new)(); @@ -1113,9 +1112,10 @@ int tms320_dasm_init(tms320_dasm_t * dasm) return 0; } -int tms320_dasm_fini(tms320_dasm_t * dasm) -{ - ht_(free)(dasm->map); - +int tms320_dasm_fini(tms320_dasm_t * dasm) { + if (dasm && dasm->map) + ht_(free)(dasm->map); + /* avoid double free */ + memset (dasm, 0, sizeof (tms320_dasm_t)); return 0; } diff --git a/libr/util/ht.c b/libr/util/ht.c index b601cdf960..47e731627c 100644 --- a/libr/util/ht.c +++ b/libr/util/ht.c @@ -166,7 +166,10 @@ R_API RHT* ht_(new)(void) { } R_API void ht_(free)(RHT *ht) { - if (ht) free (ht->table), free (ht); + if (ht) { + free (ht->table); + free (ht); + } } R_API void *ht_(lookup)(RHT *ht, utH hash) {