aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-01-08 09:28:03 +0100
committerJohn Högberg <[email protected]>2018-01-08 09:28:03 +0100
commit68a0f569410f7375c44a9d806930b1172c1d92a8 (patch)
tree4c2f6d8714613a068b74d115b5e8e725161f885b /erts/emulator/beam/utils.c
parente2367ba51d0cc0cb4a65fd39d1a8b7bd943efe8e (diff)
parent185a0cdc2d0f72d64768dc6dd5465ad6fe561028 (diff)
downloadotp-68a0f569410f7375c44a9d806930b1172c1d92a8.tar.gz
otp-68a0f569410f7375c44a9d806930b1172c1d92a8.tar.bz2
otp-68a0f569410f7375c44a9d806930b1172c1d92a8.zip
Merge branch 'john/erts/putenv-thread-safety/OTP-14666'
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index 993585be10..fe9f1c7606 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -4360,15 +4360,20 @@ erts_read_env(char *key)
char *value = erts_alloc(ERTS_ALC_T_TMP, value_len);
int res;
while (1) {
- res = erts_sys_getenv_raw(key, value, &value_len);
- if (res <= 0)
- break;
- value = erts_realloc(ERTS_ALC_T_TMP, value, value_len);
+ res = erts_sys_explicit_8bit_getenv(key, value, &value_len);
+
+ if (res >= 0) {
+ break;
+ }
+
+ value = erts_realloc(ERTS_ALC_T_TMP, value, value_len);
}
- if (res != 0) {
- erts_free(ERTS_ALC_T_TMP, value);
- return NULL;
+
+ if (res != 1) {
+ erts_free(ERTS_ALC_T_TMP, value);
+ return NULL;
}
+
return value;
}