Skip to content

Commit

Permalink
fix incorrect parsing of names for custom csr registers
Browse files Browse the repository at this point in the history
  • Loading branch information
aap-sc committed Nov 27, 2024
1 parent eb1ecd7 commit 6280641
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -4164,12 +4164,16 @@ static int parse_reg_ranges_impl(struct list_head *ranges, char *args,
}

const char * const reg_name_in = equals + 1;
*name_buffer = calloc(1, strlen(reg_name_in) + strlen(reg_type) + 2);
const size_t reg_type_len = strlen(reg_type);
/* format is: <reg_type>_<reg_name_in>\0 */
*name_buffer = calloc(1, strlen(reg_name_in) + reg_type_len + 2);
name = *name_buffer;
if (!name) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
strncpy(name, reg_type, reg_type_len);
name[reg_type_len] = '_';

unsigned int scanned_chars;
char *scan_dst = name + strlen(reg_type) + 1;
Expand Down

0 comments on commit 6280641

Please sign in to comment.