mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 19:47:31 +00:00
Fix crash in tms320 finalization
This commit is contained in:
parent
9297d3d688
commit
b8532a0679
@ -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 = {
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user