X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perlio.c;h=ddcc357c53569a4157c7a91cbec02f993270dfce;hb=8d08d9baca8b5e17813fd3fbfe3510d7ba6097f7;hp=7da7505045ae2ee54119e1de0a4017689a5c4ad4;hpb=ef8d46e8143455a8b73aff3ecaa10ca3cf293a4d;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perlio.c b/perlio.c index 7da7505..ddcc357 100644 --- a/perlio.c +++ b/perlio.c @@ -5157,16 +5157,18 @@ PerlIO_tmpfile(void) int fd = -1; char tempname[] = "/tmp/PerlIO_XXXXXX"; const char * const tmpdir = PL_tainting ? NULL : PerlEnv_getenv("TMPDIR"); - SV * const sv = tmpdir && *tmpdir ? newSVpv(tmpdir, 0) : NULL; + SV * sv; /* * I have no idea how portable mkstemp() is ... NI-S */ - if (sv) { + if (tmpdir && *tmpdir) { /* if TMPDIR is set and not empty, we try that first */ + sv = newSVpv(tmpdir, 0); sv_catpv(sv, tempname + 4); fd = mkstemp(SvPVX(sv)); } if (fd < 0) { + sv = NULL; /* else we try /tmp */ fd = mkstemp(tempname); }