From 7299ca586a6a78a40081a6e7e2e94c3b1a8aa538 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 7 Jan 2010 14:22:39 +0000 Subject: Unlink PerlIO's tempfiles for the case of no -T, but bogus $ENV{TMPDIR} When -T is enabled, or when $ENV{TMPDIR} is bogus, perlio.c used a pathname matching . However, it was only correctly unlinking the file for the case of -T enabled. --- perlio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'perlio.c') diff --git a/perlio.c b/perlio.c index 7da7505045..ddcc357c53 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); } -- cgit v1.2.1