diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | hash.c | 13 |
2 files changed, 9 insertions, 8 deletions
@@ -1,3 +1,7 @@ +Mon Jun 13 13:03:08 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> + + * hash.c (ruby_setenv): fixed SEGV. [ruby-dev:26186] + Mon Jun 13 01:54:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org> * signal.c (sigexit): call rb_thread_signal_exit() instead of @@ -1824,27 +1824,24 @@ ruby_setenv(name, value) tmpenv[max] = 0; environ = tmpenv; /* tell exec where it is now */ } - if (!value) { - if (environ != origenviron) { + if (environ[i]) { char **envp = origenviron; while (*envp && *envp != environ[i]) envp++; if (!*envp) free(environ[i]); - } + if (!value) { while (environ[i]) { environ[i] = environ[i+1]; i++; } return; } - if (!environ[i]) { /* does not exist yet */ + } + else { /* does not exist yet */ + if (!value) return; REALLOC_N(environ, char*, i+2); /* just expand it a bit */ environ[i+1] = 0; /* make sure it's null terminated */ } - else { - if (environ[i] != origenviron[i]) - free(environ[i]); - } environ[i] = ALLOC_N(char, strlen(name) + strlen(value) + 2); #ifndef MSDOS sprintf(environ[i],"%s=%s",name,value); /* all that work just for this */ |