target/riscv: Prevent dump_field() reading uninitialized memory

Change-Id: I9ef8f2c2e9a824aa6595e8f20682c968ae5aed72
Signed-off-by: Tim Newsome <tim@sifive.com>
This commit is contained in:
Tim Newsome 2023-10-30 09:11:26 -07:00
parent 89260a5f1f
commit e474d1d54a
1 changed files with 6 additions and 1 deletions

View File

@ -354,6 +354,8 @@ static unsigned int decode_dm(char *text, unsigned int address, unsigned int dat
context, data);
}
}
if (text)
text[0] = '\0';
return 0;
}
@ -361,8 +363,11 @@ static unsigned int decode_dmi(struct target *target, char *text, unsigned int a
unsigned int data)
{
dm013_info_t *dm = get_dm(target);
if (!dm)
if (!dm) {
if (text)
text[0] = '\0';
return 0;
}
return decode_dm(text, address - dm->base, data);
}