OSDN Git Service

* environ.cc (build_env): If realloc moves envblock, move s with it.
authorcorinna <corinna>
Fri, 14 Jun 2002 14:08:05 +0000 (14:08 +0000)
committercorinna <corinna>
Fri, 14 Jun 2002 14:08:05 +0000 (14:08 +0000)
winsup/cygwin/ChangeLog
winsup/cygwin/environ.cc

index fcf4325..8f54b1a 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * environ.cc (build_env): If realloc moves envblock, move s with it.
+
 2002-06-13  Nicholas S. Wourms  <nwourms@netscape.net>
 
        * winver.rc: Add more words to copyright.
index 4d535e4..962dc42 100644 (file)
@@ -910,7 +910,16 @@ build_env (const char * const *envp, char *&envblock, int &envc,
 
          /* See if we need to increase the size of the block. */
          if (new_tl > tl)
-           envblock = (char *) realloc (envblock, 2 + (tl += len + 100));
+           {
+             char *new_envblock =
+                       (char *) realloc (envblock, 2 + (tl += len + 100));
+             /* If realloc moves the block, move `s' with it. */
+             if (new_envblock != envblock)
+               {
+                 s += new_envblock - envblock;
+                 envblock = new_envblock;
+               }
+           }
 
          memcpy (s, p, len + 1);