Fix a null-deref in afn (#16091)

This commit is contained in:
Florian Märkl 2020-03-02 14:34:58 +01:00 committed by GitHub
parent 7a314accc3
commit 9e713900e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -2555,7 +2555,7 @@ static bool __setFunctionName(RCore *core, ut64 addr, const char *_name, bool pr
RAnalFunction *fcn = r_anal_get_function_at (core->anal, addr);
if (fcn) {
RFlagItem *flag = r_flag_get (core->flags, fcn->name);
if (flag->space && strcmp (flag->space->name, R_FLAGS_FS_FUNCTIONS) == 0) {
if (flag && flag->space && strcmp (flag->space->name, R_FLAGS_FS_FUNCTIONS) == 0) {
// Only flags in the functions fs should be renamed, e.g. we don't want to rename symbol flags.
r_flag_rename (core->flags, flag, name);
} else {

View File

@ -45,6 +45,12 @@ afn @ 0x080483f4
f@F:functions~483f4,48540
?e --
f@F:*~483f4,48540
f- myfunc
afn createdflag @ 0x080483f4
?e Non-existing flags should be created
f@F:functions~483f4,48540
?e --
f@F:*~483f4,48540
EOF
EXPECT=<<EOF
0x080483f4 33 fcn.080483f4
@ -70,5 +76,13 @@ Here the flag is owned by the fcn and should be renamed:
0x08048540 92 main
0x08048540 92 sym.main
0x08048540 92 mymain
Non-existing flags should be created
0x080483f4 33 createdflag
0x08048540 92 mymain
--
0x080483f4 33 createdflag
0x08048540 92 main
0x08048540 92 sym.main
0x08048540 92 mymain
EOF
RUN