core/os: fix lookup_env_buf only working with empty buffer

This commit is contained in:
David Bader
2026-01-30 14:44:38 +01:00
parent 4b33c6a361
commit fb9377df17
9 changed files with 9 additions and 0 deletions

View File

@@ -282,6 +282,7 @@ when ODIN_NO_CRT {
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
cval := posix.getenv(cstring(raw_data(buf)))

View File

@@ -35,6 +35,7 @@ _lookup_env_buf :: proc(buf: []u8, key: string) -> (value: string, error: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
cval := posix.getenv(cstring(raw_data(buf)))

View File

@@ -88,6 +88,7 @@ _lookup_env_buf :: proc(buf: []u8, key: string) -> (value: string, error: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
sync.shared_guard(&g_env_mutex)

View File

@@ -1072,6 +1072,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {

View File

@@ -844,6 +844,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {

View File

@@ -487,6 +487,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {

View File

@@ -963,6 +963,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {

View File

@@ -891,6 +891,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {

View File

@@ -804,6 +804,7 @@ lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error)
return "", .Buffer_Full
} else {
copy(buf, key)
buf[len(key)] = 0
}
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {