Fix the crash of command fg (#2758)

This commit is contained in:
Peiwei Hu 2022-07-01 00:33:43 +08:00 committed by GitHub
parent 857419a780
commit 347d8a72f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View file

@ -136,7 +136,6 @@ static void __printRecursive(RzCore *core, RzList *flags, const char *name, RzOu
RzListIter *iter;
if (mode == RZ_OUTPUT_MODE_RIZIN && RZ_STR_ISEMPTY(name)) {
rz_cons_printf("agn root\n");
return;
}
if (rz_flag_get(core->flags, name)) {
return;
@ -299,7 +298,11 @@ RZ_IPI RzCmdStatus rz_flag_local_list_all_handler(RzCore *core, int argc, const
RZ_IPI RzCmdStatus rz_flag_graph_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state) {
RzList *flags = rz_list_newf(NULL);
rz_flag_foreach_space(core->flags, rz_flag_space_cur(core->flags), listFlag, flags);
__printRecursive(core, flags, argv[1], state->mode, 0);
if (!argv[1]) {
__printRecursive(core, flags, "", state->mode, 0);
} else {
__printRecursive(core, flags, argv[1], state->mode, 0);
}
rz_list_free(flags);
return RZ_CMD_STATUS_OK;
}

View file

@ -652,3 +652,40 @@ EXPECT=<<EOF
0x00000000 64 segment.ehdr
EOF
RUN
NAME=show the flag graph
FILE=bins/elf/ls
CMDS=<<EOF
fg section
EOF
EXPECT=<<EOF
..in
terp
it
..note.
ABI_tag
gnu.build_id
..g
nu.
hash
version
nu.version
ot
..d
yn
s
ym
tr
str
amic
ynstr
ata
..r
ela.dyn
odata
..text
..fini
..eh_frame
..bss
EOF
RUN