Skip to content

Commit

Permalink
validity check
Browse files Browse the repository at this point in the history
  • Loading branch information
liz3 committed Sep 18, 2024
1 parent 28d47a7 commit 9b3f32a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vm/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ static ObjString *allocateString(DictuVM *vm, char *chars, int length,
string->length = length;
string->chars = chars;
string->hash = hash;
string->character_len = utf8len(chars);
if(utf8valid(chars) == 0)
string->character_len = utf8len(chars);
else
string->character_len = length;
push(vm, OBJ_VAL(string));
tableSet(vm, &vm->strings, string, NIL_VAL);
pop(vm);
Expand Down

0 comments on commit 9b3f32a

Please sign in to comment.