Merge pull request #948 from riscv/uninitialized_dump

target/riscv: Prevent dump_field() reading uninitialized memory
This commit is contained in:
Tim Newsome 2023-10-31 09:48:17 -07:00 committed by GitHub
commit 51679e3e6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}