> compile NEMU
ysyx_22040000 李心杨 Linux calcite 6.1.75 #1-NixOS SMP PREEMPT_DYNAMIC Thu Jan 25 23:27:52 UTC 2024 x86_64 GNU/Linux 19:00:00 up 1 day 4:35, 2 users, load average: 0.39, 0.65, 0.72
This commit is contained in:
parent
7b5f53a170
commit
f4813afbdc
1 changed files with 3 additions and 3 deletions
|
@ -76,13 +76,13 @@ int wp_add(char * expr) {
|
||||||
tail->next = wp;
|
tail->next = wp;
|
||||||
tail = wp;
|
tail = wp;
|
||||||
}
|
}
|
||||||
int len = strlen(expr) + 1;
|
int len = strlen(expr);
|
||||||
wp->expr = malloc(len * sizeof(char));
|
wp->expr = malloc((len + 1) * sizeof(char));
|
||||||
if (wp->expr == NULL) {
|
if (wp->expr == NULL) {
|
||||||
Error("Failed to allocate memory for expression");
|
Error("Failed to allocate memory for expression");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
strncpy(wp->expr, expr, len);
|
strncpy(wp->expr, expr, len + 1);
|
||||||
wp->expr[len - 1] = '\0';
|
wp->expr[len - 1] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue