aboutsummaryrefslogtreecommitdiff
path: root/core/runtime
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2023-08-22 20:18:54 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2023-08-22 20:18:54 +0200
commit74bbb1167f45a9e57d25b2946b0fcd8396dc4c77 (patch)
treec7e5e38979c3670ec3bfab9eebf85ad2e309ec91 /core/runtime
parent515163864f4151514f7f29f57337f6540d93c2c7 (diff)
Fix #2763
Fixes #2763
Diffstat (limited to 'core/runtime')
-rw-r--r--core/runtime/core_builtin.odin11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin
index 9f2899bcc..6ddd12a5e 100644
--- a/core/runtime/core_builtin.odin
+++ b/core/runtime/core_builtin.odin
@@ -601,14 +601,15 @@ assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c
@builtin
assign_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
- if len(args) == 0 {
+ new_size := index + len(arg)
+ if len(arg) == 0 {
ok = true
- } else if index+len(args) < len(array) {
- copy(array[index:], args)
+ } else if new_size < len(array) {
+ copy(array[index:], arg)
ok = true
} else {
- resize(array, index+1+len(args), loc) or_return
- copy(array[index:], args)
+ resize(array, new_size, loc) or_return
+ copy(array[index:], arg)
ok = true
}
return