From 9936a1dbe6a87d3a9fe6d02e1202fcfb5018d18c Mon Sep 17 00:00:00 2001 From: cyanpencil Date: Mon, 21 May 2018 21:26:25 +0200 Subject: [PATCH] Updated ag? help Fixed segfault in r_str_trunc_ellipsis() Fix agC* command Fix callgraph bug not resetting is_callgraph --- libr/core/cmd_anal.c | 8 +++++++- libr/core/graph.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 72373851f41d6..4bd6202544dfd 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -388,6 +388,9 @@ static const char *help_msg_ag[] = { "aga", "[format] [fcn addr]", "Data references graph", "agd", "[format] [fcn addr]", "Diff graph", "agi", "[format]", "Imports graph", + "agC", "[format]", "Global callgraph", + "agR", "[format]", "Global references graph", + "agA", "[format]", "Global data references graph", "agg", "[format]", "Custom graph", "ag-", "", "Clear the custom graph", "agn", "[?] title body", "Add a node to the custom graph", @@ -5894,11 +5897,12 @@ static void cmd_anal_graph(RCore *core, const char *input) { case ' ': case 0: { core->graph->is_callgraph = true; - char *cmd = r_str_newf ("ag-; .agc* %lld; agg%c;", UT64_MAX, input[1]); + char *cmd = r_str_newf ("ag-; .agC*; agg%c;", input[1]); if (cmd && *cmd) { r_core_cmd0 (core, cmd); } free (cmd); + core->graph->is_callgraph = false; break; } case 'J': @@ -6046,12 +6050,14 @@ static void cmd_anal_graph(RCore *core, const char *input) { if (cmd && *cmd) { r_core_cmd0 (core, cmd); } + core->graph->is_callgraph = false; free (cmd); break; } case 0: core->graph->is_callgraph = true; r_core_cmd0 (core, "ag-; .agc* $$; agg;"); + core->graph->is_callgraph = false; break; case 'g': { ut64 addr = input[2] ? r_num_math (core->num, input + 2): core->offset; diff --git a/libr/core/graph.c b/libr/core/graph.c index 8dc714ed9078e..aa43b09ea442e 100644 --- a/libr/core/graph.c +++ b/libr/core/graph.c @@ -3429,7 +3429,7 @@ R_API RANode *r_agraph_get_first_node(const RAGraph *g) { } R_API RANode *r_agraph_get_node(const RAGraph *g, const char *title) { - char *title_trunc = r_str_trunc_ellipsis (title, 255); + char *title_trunc = title ? r_str_trunc_ellipsis (title, 255) : NULL; RANode *node = (RANode *) (size_t) sdb_num_get (g->nodes, title_trunc, NULL); free (title_trunc); return node;