From 470e8c460d8ef8cd60d2d528498e8b07bbcda6dc Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 14 Jun 2002 14:08:07 +0000 Subject: [PATCH] * environ.cc (build_env): If realloc moves envblock, move s with it. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/environ.cc | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fcf4325e1..8f54b1a73 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2002-06-14 Corinna Vinschen + + * environ.cc (build_env): If realloc moves envblock, move s with it. + 2002-06-13 Nicholas S. Wourms * winver.rc: Add more words to copyright. diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4d535e436..962dc42f9 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -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);