Fix null deref in agg and avoid destructive manners of 'V ,' ##graph

This commit is contained in:
pancake 2022-10-21 02:46:43 +02:00
parent 241aff8d37
commit 5b85e61517
3 changed files with 8 additions and 4 deletions

View File

@ -3208,6 +3208,9 @@ static void agraph_set_zoom(RAGraph *g, int v) {
* (callgraph, CFG, etc.), set the default layout for these nodes and center
* the screen on the selected one */
static bool agraph_reload_nodes(RAGraph *g, RCore *core, RAnalFunction *fcn) {
if (g->is_handmade) {
return true;
}
r_agraph_reset (g);
return reload_nodes (g, core, fcn);
}
@ -3364,7 +3367,7 @@ static bool check_changes(RAGraph *g, int is_interactive, RCore *core, RAnalFunc
int oldpos[2] = {
0, 0
};
if (g->update_seek_on && r_config_get_i (core->config, "graph.few")) {
if (g->update_seek_on && core && r_config_get_i (core->config, "graph.few")) {
g->need_reload_nodes = true;
}
if (g->need_reload_nodes && core) {
@ -3525,7 +3528,7 @@ static int agraph_print(RAGraph *g, int is_interactive, RCore *core, RAnalFuncti
g->can = _can;
char *s = strdup (r_cons_singleton()->context->buffer);
r_cons_pop ();
cmd_agfb3 (core, s, w-40, 2);
cmd_agfb3 (core, s, w - 40, 2);
free (s);
g->can->h /= 4;
r_cons_flush ();
@ -3553,11 +3556,9 @@ static int agraph_refresh(struct agraph_refresh_data *grd) {
RAGraph *g = grd->g;
RAnalFunction *f = NULL;
RAnalFunction **fcn = grd->fcn;
if (!fcn) {
return agraph_print (g, grd->fs, core, NULL);
}
// allow to change the current function during debugging
if (g->is_instep && r_config_get_b (core->config, "cfg.debug")) {
// seek only when the graph node changes

View File

@ -10246,12 +10246,14 @@ R_API void r_core_agraph_print(RCore *core, int use_utf, const char *input) {
r_agraph_set_curnode (core->graph, ran);
core->graph->force_update_seek = true;
core->graph->need_set_layout = true;
core->graph->is_handmade = true;
core->graph->layout = r_config_get_i (core->config, "graph.layout");
bool ov = r_cons_is_interactive ();
core->graph->need_update_dim = true;
int update_seek = r_core_visual_graph (core, core->graph, NULL, true);
r_config_set_b (core->config, "scr.interactive", ov);
r_cons_show_cursor (true);
core->graph->is_handmade = false;
r_cons_enable_mouse (false);
if (update_seek != -1) {
r_core_seek (core, oseek, false);

View File

@ -61,6 +61,7 @@ typedef struct r_ascii_graph_t {
int is_instep;
bool is_tiny;
bool is_dis;
bool is_handmade;
int edgemode;
int mode;
bool is_callgraph;