summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-01-07 14:22:39 +0000
committerNicholas Clark <nick@ccl4.org>2010-01-07 14:22:39 +0000
commit7299ca586a6a78a40081a6e7e2e94c3b1a8aa538 (patch)
treeebb86caff5956dc6188981de9ab92d9a230cd3f6 /perlio.c
parentc1bf414cd50bd38fc03b19662a57f8bcb9008994 (diff)
downloadperl-7299ca586a6a78a40081a6e7e2e94c3b1a8aa538.tar.gz
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 </tmp/PerlIO_??????>. However, it was only correctly unlinking the file for the case of -T enabled.
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c6
1 files changed, 4 insertions, 2 deletions
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);
}