Skip to content

Commit

Permalink
Fix string concatenation.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoNex committed Oct 23, 2023
1 parent 4f59841 commit ef56830
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ static inline void vm_exec_add(struct vm * restrict vm) {
} else if (M_ASSERT(left, right, obj_string)) {
size_t slen = left->data.str->len + right->data.str->len;
char *str = malloc(sizeof(char) * (slen + 1));
char *start = strcpy(str, left->data.str->str);
strcpy(start, right->data.str->str);
char *p = stpcpy(stpcpy(str, left->data.str->str), right->data.str->str);
*p = '\0';
vm_stack_pop_ignore(vm);
struct object res = new_string_obj(str, slen);
vm_stack_push(vm, res);
Expand Down

0 comments on commit ef56830

Please sign in to comment.