]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(__add_to_environ): Initialize ep after we have the lock.
authorUlrich Drepper <drepper@redhat.com>
Thu, 19 Aug 1999 20:11:33 +0000 (20:11 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 19 Aug 1999 20:11:33 +0000 (20:11 +0000)
Avoid warning about uninitialized variable.

sysdeps/generic/setenv.c

index fc58e9b34630fc3e61bf17e1adf920a31409c961..29fc60c3fb33fc35977277a572fd6eb25065c6a9 100644 (file)
@@ -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