Fix asan issue with graph initialization

This commit is contained in:
pancake 2018-03-07 12:47:39 +01:00
parent d1c5cda030
commit 6428824bc6
3 changed files with 20 additions and 10 deletions

View File

@ -9,9 +9,11 @@
#define G(x, y) r_cons_canvas_gotoxy (c, x, y)
R_API void r_cons_canvas_free(RConsCanvas *c) {
free (c->b);
free (c->attrs);
free (c);
if (c) {
free (c->b);
free (c->attrs);
free (c);
}
}
R_API void r_cons_canvas_clear(RConsCanvas *c) {

View File

@ -5670,11 +5670,19 @@ static void cmd_agraph_print(RCore *core, const char *input) {
r_core_cmd_help (core, help_msg_agg);
break;
default:
core->graph->can->linemode = r_config_get_i (core->config, "graph.linemode");
core->graph->can->color = r_config_get_i (core->config, "scr.color");
r_agraph_set_title (core->graph,
r_config_get (core->config, "graph.title"));
r_agraph_print (core->graph);
if (!core->graph) {
core->graph = r_agraph_new (NULL, r_config_get_i (core->config, "graph.dummy"));
}
if (core->graph) {
if (!core->graph->can) {
core->graph->can = r_cons_canvas_new (1, 1);
}
core->graph->can->linemode = r_config_get_i (core->config, "graph.linemode");
core->graph->can->color = r_config_get_i (core->config, "scr.color");
r_agraph_set_title (core->graph,
r_config_get (core->config, "graph.title"));
r_agraph_print (core->graph);
}
break;
}
}

View File

@ -1840,8 +1840,6 @@ R_API bool r_core_init(RCore *core) {
core->fs = r_fs_new ();
core->flags = r_flag_new ();
core->flags->cb_printf = r_cons_printf;
core->graph = r_agraph_new (r_cons_canvas_new (1, 1), r_config_get_i (core->config, "graph.dummy"));
core->graph->need_reload_nodes = false;
core->asmqjmps_size = R_CORE_ASMQJMPS_NUM;
if (sizeof (ut64) * core->asmqjmps_size < core->asmqjmps_size) {
core->asmqjmps_size = 0;
@ -1901,6 +1899,8 @@ R_API bool r_core_init(RCore *core) {
r_config_set (core->config, "asm.arch", R_SYS_ARCH);
r_bp_use (core->dbg->bp, R_SYS_ARCH, core->anal->bits);
update_sdb (core);
core->graph = r_agraph_new (NULL, r_config_get_i (core->config, "graph.dummy"));
core->graph->need_reload_nodes = false;
return 0;
}