diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-01-07 14:22:39 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-01-07 14:22:39 +0000 |
commit | 7299ca586a6a78a40081a6e7e2e94c3b1a8aa538 (patch) | |
tree | ebb86caff5956dc6188981de9ab92d9a230cd3f6 /perlio.c | |
parent | c1bf414cd50bd38fc03b19662a57f8bcb9008994 (diff) | |
download | perl-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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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); } |