diff options
| author | Rickard Andersson <gonz@severnatazvezda.com> | 2023-06-27 21:48:53 +0300 |
|---|---|---|
| committer | Rickard Andersson <gonz@severnatazvezda.com> | 2023-06-27 21:48:53 +0300 |
| commit | f048ad13b52d3c2be2fcd975f1039eb88604360f (patch) | |
| tree | cbffc3de9428fe7de1b8e10abeb4b4114b5a0032 | |
| parent | d03d5d8f038ee5f964edd9e40441b9027c91f180 (diff) | |
fix(set_env): use `clone_to_cstring` instead of `unsafe_to_cstring`
| -rw-r--r-- | core/os/os_linux.odin | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 0a3bdbb9e..1a4c1fddb 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -894,8 +894,8 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) set_env :: proc(key, value: string) -> Errno { runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() - key_cstring := strings.unsafe_string_to_cstring(strings.concatenate({key, "\x00"}, context.temp_allocator)) - value_cstring := strings.unsafe_string_to_cstring(strings.concatenate({value, "\x00"}, context.temp_allocator)) + key_cstring := strings.clone_to_cstring(key, context.temp_allocator) + value_cstring := strings.clone_to_cstring(value, context.temp_allocator) // NOTE(GoNZooo): `setenv` instead of `putenv` because it copies both key and value more commonly res := _unix_setenv(key_cstring, value_cstring, 1) if res < 0 { |