refactor: extract wrenNewUninitializedString to avoid passing NULL to wrenNewString for empty buffers
This commit is contained in:
+1
-1
@@ -957,7 +957,7 @@ DEF_NATIVE(string_subscript)
|
||||
|
||||
// The result is a one-character string.
|
||||
// TODO: Handle UTF-8.
|
||||
Value value = wrenNewString(vm, NULL, 2);
|
||||
Value value = wrenNewUninitializedString(vm, 2);
|
||||
ObjString* result = AS_STRING(value);
|
||||
result->value[0] = AS_CSTRING(args[0])[index];
|
||||
result->value[1] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user