Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incorrect parsing of names for custom csr registers #1176

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
strcpy(name, reg_type);
name[reg_type_len] = '_';

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