Skip to content

Commit

Permalink
target/riscv: fix segfault on RISC-V Debug v0.11
Browse files Browse the repository at this point in the history
Change-Id: I5be9153f364a5ad5083e809f479aed5378e420c9
  • Loading branch information
en-sc committed Apr 19, 2024
1 parent 3991492 commit 979a361
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -6194,14 +6194,10 @@ static int resize_reg(const struct target *target, uint32_t regno, bool exist,
free(reg->value);
reg->size = size;
reg->exist = exist;
if (reg->exist) {
reg->value = malloc(DIV_ROUND_UP(reg->size, 8));
if (!reg->value) {
LOG_ERROR("Failed to allocate memory.");
return ERROR_FAIL;
}
} else {
reg->value = NULL;
reg->value = malloc(DIV_ROUND_UP(reg->size, 8));
if (!reg->value) {
LOG_ERROR("Failed to allocate memory.");
return ERROR_FAIL;
}
assert(reg_is_initialized(reg));
return ERROR_OK;
Expand Down

0 comments on commit 979a361

Please sign in to comment.