http://rt.perl.org/rt3/Ticket/Display.html?id=56500 _THIS COULD HAVE BEEN MUCH WORSE_ Lubomir Rintel diff -urp Term-ReadLine-Gnu-1.17.orig/Gnu.pm Term-ReadLine-Gnu-1.17/Gnu.pm --- Term-ReadLine-Gnu-1.17.orig/Gnu.pm 2008-02-07 15:12:43.000000000 +0100 +++ Term-ReadLine-Gnu-1.17/Gnu.pm 2008-07-01 18:36:50.000000000 +0200 @@ -68,6 +68,11 @@ END } } +# Tidy up what could have been malloc()'d +END { + new Term::ReadLine::Gnu->env_workaround (); +} + { use Exporter (); use DynaLoader; diff -urp Term-ReadLine-Gnu-1.17.orig/Gnu.xs Term-ReadLine-Gnu-1.17/Gnu.xs --- Term-ReadLine-Gnu-1.17.orig/Gnu.xs 2008-02-06 15:49:47.000000000 +0100 +++ Term-ReadLine-Gnu-1.17/Gnu.xs 2008-07-01 18:21:59.000000000 +0200 @@ -1317,6 +1317,32 @@ MODULE = Term::ReadLine::Gnu PACKAGE = # 2.1 Basic Behavior # +void +env_workaround() + PROTOTYPE: + CODE: + { + int i; + char **envptr; + // We intentionally not free old pointers, + // given we can't really sure where do they come from + // and how were they allocated + for (i = 0; environ[i] != NULL; i++) { + char *oldptr; + + if (strncmp (environ[i], "LINES=", 6) == 0 || + strncmp (environ[i], "COLUMNS=", 8) == 0) { + oldptr = environ[i]; + environ[i] = safesysmalloc (strlen (oldptr)+1); + strcpy (environ[i], oldptr); + } + } + i++; + envptr = safesysmalloc (sizeof (environ) * i); + memcpy (envptr, environ, sizeof (environ) * i); + environ = envptr; + } + # The function name "readline()" is reserved for a method name. t_xstr