Skip to content

Commit

Permalink
Merge pull request #5 from tobiasfrejo/array-access-fix
Browse files Browse the repository at this point in the history
Array access fix
  • Loading branch information
NValsted authored Apr 24, 2024
2 parents 6173234 + 04e3308 commit 776767b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/proc_runtime_instructions_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,20 @@ double float_abs(double x) {
}

int proc_param_scan_offset(char * arg) {
char * arg_copy = proc_strdup(arg);
char * saveptr;
char * token;
int offset = -1;

strtok_r(arg, "[", &saveptr);
strtok_r(arg_copy, "[", &saveptr);
token = strtok_r(NULL, "[", &saveptr);
if (token != NULL) {
sscanf(token, "%d", &offset);
*token = '\0';
}

proc_free(arg_copy);

return offset;
}

Expand All @@ -185,7 +188,7 @@ param_t * proc_fetch_param(char * param_name, int node) {
int offset = proc_param_scan_offset(param_name_copy);
if (offset != -1) {
int index_length = snprintf(NULL, 0, "%d", offset);
param_name_copy[strlen(param_name_copy) - index_length + 1] = '\0';
param_name_copy[strlen(param_name_copy) - (index_length + 2)] = '\0';
}

csp_iface_t * ifaces = csp_iflist_get();
Expand Down

0 comments on commit 776767b

Please sign in to comment.