diff --git a/libr/anal/meta.c b/libr/anal/meta.c index 9ba52f0de8..a4cc9f1670 100644 --- a/libr/anal/meta.c +++ b/libr/anal/meta.c @@ -700,12 +700,8 @@ static int meta_print_item(void *user, const char *k, const char *v) { if (!meta_deserialize (&it, k, v)) { return 1; } - int uirad = ui->rad; - if (ui->rad == 'f') { - if (!r_anal_fcn_in (ui->fcn, it.from)) { - goto beach; - } - ui->rad = 0; + if (ui->fcn && !r_anal_fcn_in (ui->fcn, it.from)) { + goto beach; } if (!it.str) { it.str = strdup (""); // don't break in free @@ -716,19 +712,26 @@ static int meta_print_item(void *user, const char *k, const char *v) { r_meta_print (ui->anal, &it, ui->rad, true); beach: free (it.str); - ui->rad = uirad; return 1; } R_API int r_meta_list_cb(RAnal *a, int type, int rad, SdbForeachCallback cb, void *user, ut64 addr) { - RAnalFunction *fcn = (addr != UT64_MAX) ? r_anal_get_fcn_at (a, addr, 0) : NULL; - RAnalMetaUserItem ui = { a, type, rad, cb, user, 0, fcn}; - SdbList *ls = sdb_foreach_list (DB, true); - SdbListIter *lsi; - SdbKv *kv; if (rad == 'j') { a->cb_printf ("["); } + + RAnalMetaUserItem ui = { a, type, rad, cb, user, 0, NULL }; + + if (addr != UT64_MAX) { + ui.fcn = r_anal_get_fcn_in (a, addr, 0); + if (!ui.fcn) { + goto beach; + } + } + + SdbList *ls = sdb_foreach_list (DB, true); + SdbListIter *lsi; + SdbKv *kv; isFirst = true; // TODO: kill global ls_foreach (ls, lsi, kv) { if (type == R_META_TYPE_ANY || (strlen (sdbkv_key (kv)) > 5 && sdbkv_key (kv)[5] == type)) { @@ -740,6 +743,8 @@ R_API int r_meta_list_cb(RAnal *a, int type, int rad, SdbForeachCallback cb, voi } } ls_free (ls); + +beach: if (rad == 'j') { a->cb_printf ("]\n"); } diff --git a/libr/core/cmd_meta.c b/libr/core/cmd_meta.c index 1dea9160cb..5e37afa783 100644 --- a/libr/core/cmd_meta.c +++ b/libr/core/cmd_meta.c @@ -388,8 +388,11 @@ static int cmd_meta_comment(RCore *core, const char *input) { case 'j': // "CCfj" r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 'j', core->offset); break; + case '*': // "CCf*" + r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 1, core->offset); + break; default: - r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 'f', core->offset); + r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 0, core->offset); break; } break;