Use correct buffer size in string subscript operator.
This commit is contained in:
+1
-1
@@ -968,7 +968,7 @@ DEF_NATIVE(string_subscript)
|
||||
|
||||
// The result is a one-character string.
|
||||
// TODO: Handle UTF-8.
|
||||
Value value = wrenNewUninitializedString(vm, 2);
|
||||
Value value = wrenNewUninitializedString(vm, 1);
|
||||
ObjString* result = AS_STRING(value);
|
||||
result->value[0] = AS_CSTRING(args[0])[index];
|
||||
result->value[1] = '\0';
|
||||
|
||||
+1
-1
@@ -341,7 +341,7 @@ Value wrenNewUninitializedString(WrenVM* vm, size_t length)
|
||||
{
|
||||
ObjString* string = allocate(vm, sizeof(ObjString) + length + 1);
|
||||
initObj(vm, &string->obj, OBJ_STRING, vm->stringClass);
|
||||
string->length = length;
|
||||
string->length = (int)length;
|
||||
|
||||
return OBJ_VAL(string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user