From 9c4140bada25cc97aaf407e2f43336a512f5139e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 19 Aug 1999 20:11:33 +0000 Subject: [PATCH] (__add_to_environ): Initialize ep after we have the lock. Avoid warning about uninitialized variable. --- sysdeps/generic/setenv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c index fc58e9b346..29fc60c3fb 100644 --- a/sysdeps/generic/setenv.c +++ b/sysdeps/generic/setenv.c @@ -120,17 +120,21 @@ __add_to_environ (name, value, combined, replace) 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 (__environ != NULL) + if (ep != NULL) { - for (ep = __environ; *ep != NULL; ++ep) + for (; *ep != NULL; ++ep) if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') break; else ++size; } - if (__environ == NULL || *ep == NULL) + if (ep == NULL || *ep == NULL) { char **new_environ; #ifdef USE_TSEARCH