diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-07-09 09:38:45 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-07-09 09:38:45 +0000 |
commit | 439ba5457a8422144686c1df300aa1dde218dbfd (patch) | |
tree | 8a8cfa96fb47bcc6b7fcce09faa7b079a0d9e17c /perlio.c | |
parent | 526d96c3e19e37c3a741435e361e1731394e2c2d (diff) | |
download | perl-439ba5457a8422144686c1df300aa1dde218dbfd.tar.gz |
Core-dump prevention for
open PIPE, "-|:stdio", "cat /etc/motd";
(root cause not yet fixed).
p4raw-id: //depot/perlio@17432
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2433,7 +2433,12 @@ typedef struct { IV PerlIOStdio_fileno(pTHX_ PerlIO *f) { - return PerlSIO_fileno(PerlIOSelf(f, PerlIOStdio)->stdio); + FILE *s; + if (PerlIOValid(f) && (s = PerlIOSelf(f, PerlIOStdio)->stdio)) { + return PerlSIO_fileno(s); + } + errno = EBADF; + return -1; } char * @@ -2631,6 +2636,10 @@ PerlIOStdio_close(pTHX_ PerlIO *f) Sock_size_t optlen = sizeof(int); #endif FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio; + if (!stdio) { + errno = EBADF; + return -1; + } if (PerlIOUnix_refcnt_dec(fileno(stdio)) > 0) { /* Do not close it but do flush any buffers */ return PerlIO_flush(f); @@ -4619,3 +4628,4 @@ PerlIO_sprintf(char *s, int n, const char *fmt, ...) + |