From: Ulrich Drepper Date: Thu, 19 Aug 1999 20:11:33 +0000 (+0000) Subject: (__add_to_environ): Initialize ep after we have the lock. X-Git-Tag: cvs/glibc_2-1-2~116 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c4140bada25cc97aaf407e2f43336a512f5139e;p=thirdparty%2Fglibc.git (__add_to_environ): Initialize ep after we have the lock. Avoid warning about uninitialized variable. --- diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c index fc58e9b3463..29fc60c3fb3 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