aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/generic/setenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/setenv.c')
-rw-r--r--sysdeps/generic/setenv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c
index 387152dcad..29fc60c3fb 100644
--- a/sysdeps/generic/setenv.c
+++ b/sysdeps/generic/setenv.c
@@ -113,13 +113,17 @@ __add_to_environ (name, value, combined, replace)
const char *combined;
int replace;
{
- register char **ep = __environ;
+ register char **ep;
register size_t size;
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
LOCK;
+ /* We have to get the pointer now that we have the lock and not earlier
+ since another thread might have created a new environment. */
+ ep = __environ;
+
size = 0;
if (ep != NULL)
{