From: Marc Singer Subject: Re: Patch for tmpnam() (v2) To: nbn.nbn.com!sapien!prl.philips.nl!kunst (Pieter Kunst) Date: Mon, 4 Sep 1995 11:41:28 -0700 (PDT) Cc: nbn.nbn.com!sapien!sun.soe.clarkson.edu!djgpp (DJGPP List Alias) According to Pieter Kunst: > > In article Marc Singer writes: > >Ok. It isn;t really a `patch'. Here is a version of tmpname() that > >does not bomb if $TMP doesn't end with a path separator. > > > [rest of code deleted...] > > > This code might not work properly with the following sequence: > > tmpnam(); /* tmp_dir points to getenv() static data buffer */ > getenv("SOMEVAR"); /* subsequent call to getenv() fills static data */ > tmpnam(); /* might fail due to static data overwrite */ > /* i.e. tmp_dir points to SOMEVAR getenv() result */ > > Better make a local copy of the getenv() result. > > Pieter. > I am not sure you understand the code. The getenv() call will not clobber the buffer used by tmpnam(). It is true that successive calls to tmpnam() with NULL parameters will clobber intermediate results, but this is easily fixed by providing your own buffer. The GNU compiler (with prototype checking) will not accept the code you write because tmpnam() requires a parameter. ---------------------------------------------------------------------- Marc Singer | "... but when you eat this ... pear, you elf AT netcom DOT com | are rarely aware of the fact that it was or elf AT sapien DOT com | ... plucked from the branch of this ... < My comments are my own. > | pear tree." -- Charlie V.