* environ.cc (build_env): If realloc moves envblock, move s with it.

This commit is contained in:
Corinna Vinschen 2002-06-14 14:08:07 +00:00
parent ced1e577b7
commit 470e8c460d
2 changed files with 14 additions and 1 deletions

View 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.

View 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);