Skip to content

Commit

Permalink
r2pipe2: show error when command execution returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed May 27, 2024
1 parent f2bdb95 commit f7c0e05
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3357,17 +3357,21 @@ static int cmd_json(void *data, const char *input) {
r_log_add_callback (stderr_cb, stderr_list);
char *res = r_core_cmd_str (core, r_cmd);
r_log_del_callback (stderr_cb);
if (is_trim) {
r_str_trim (res);
}
if (is_json) {
pj_k (pj, "res");
pj_raw (pj, res);
if (res) {
if (is_trim) {
r_str_trim (res);
}
if (is_json) {
pj_k (pj, "res");
pj_raw (pj, res);
} else {
pj_ks (pj, "res", res);
}
free (res);
pj_kb (pj, "error", false);
} else {
pj_ks (pj, "res", res);
pj_kb (pj, "error", true);
}
free (res);
pj_kb (pj, "error", false);
pj_kn (pj, "value", core->num->value);
pj_kn (pj, "code", core->rc);
if (!r_list_empty (stderr_list)) {
Expand Down

0 comments on commit f7c0e05

Please sign in to comment.