summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-07-09 09:38:45 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-07-09 09:38:45 +0000
commit439ba5457a8422144686c1df300aa1dde218dbfd (patch)
tree8a8cfa96fb47bcc6b7fcce09faa7b079a0d9e17c /perlio.c
parent526d96c3e19e37c3a741435e361e1731394e2c2d (diff)
downloadperl-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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/perlio.c b/perlio.c
index 7c06b5a677..b4b23d4830 100644
--- a/perlio.c
+++ b/perlio.c
@@ -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, ...)
+