[gnu.emacs.bug] Minor bug in sysdep.c for VMS

darin@UCBVAX.BERKELEY.EDU (Darin Johnson) (04/18/89)

I recently copied over Gnu Emacs 18.52 from my Unix systems to update
what we have on VMS.  In the file sysdep.c, the routine sys_getenv
does some special processing to get an environment variable.  What
has changed since version 18.50, is that the routine now explicitly
checks for logical names before calling VAXC's builtin getenv.  This
is good, since it lets the user override the TERM environment variable.
However, when translating logical names, the code puts the translation
into a static variable, and returns a pointer to that.  Later, when
sys_getenv is called again, this static area gets overwritten, changing
previous getenv()s.  Since this static area is only used part of the time,
the problem may not have shown up in all cases.  It did fail however,
when TERM was defined as a logical name, causing getenv("TERMCAP") in
tgetent() to overwrite it (I am also using shared libraries, if that
makes a difference).  The fix that I used was to change the line that
reads "return buf;" so that a new string was malloc()ed, buf copied
into it, and the new string returned.

Darin Johnson (leadsv!laic!darin@pyramid.pyramid.com)