summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-12 13:27:44 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-12 13:27:44 +0000
commit67363c0d4f1afeee7e193e700845c9f68327d8c8 (patch)
tree9e0215bbff879602e17e79dc69e9276b4b93242c /perlio.c
parent18aba96f40a877297fb70961dbd4be7bc6f1c199 (diff)
downloadperl-67363c0d4f1afeee7e193e700845c9f68327d8c8.tar.gz
More perlio ->Open paranoia. Set errno to EINVAL if there's
no ->Open, not if ->Open returns NULL. p4raw-id: //depot/perl@19749
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/perlio.c b/perlio.c
index 38db370b62..78b2d18be5 100644
--- a/perlio.c
+++ b/perlio.c
@@ -3405,9 +3405,12 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers,
{
if (PerlIOValid(f)) {
PerlIO *next = PerlIONext(f);
- PerlIO_funcs *tab = PerlIO_layer_fetch(aTHX_ layers, n - 1, PerlIOBase(next)->tab);
- next = (*tab->Open) (aTHX_ tab, layers, n - 1, mode, fd, imode, perm,
- next, narg, args);
+ PerlIO_funcs *tab =
+ PerlIO_layer_fetch(aTHX_ layers, n - 1, PerlIOBase(next)->tab);
+ if (tab && tab->Open)
+ next =
+ (*tab->Open)(aTHX_ tab, layers, n - 1, mode, fd, imode, perm,
+ next, narg, args);
if (!next || (*PerlIOBase(f)->tab->Pushed) (aTHX_ f, mode, PerlIOArg, self) != 0) {
return NULL;
}
@@ -3421,10 +3424,11 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers,
* mode++;
*/
}
- f = tab && tab->Open ?
- (*tab->Open) (aTHX_ tab, layers, n - 1, mode, fd, imode, perm,
- f, narg, args)
- : Nullfp;
+ if (tab && tab->Open)
+ f = (*tab->Open)(aTHX_ tab, layers, n - 1, mode, fd, imode, perm,
+ f, narg, args);
+ else
+ SETERRNO(EINVAL, LIB_INVARG);
if (f) {
if (PerlIO_push(aTHX_ f, self, mode, PerlIOArg) == 0) {
/*
@@ -3453,8 +3457,6 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers,
#endif
}
}
- else
- SETERRNO(EINVAL, SS_IVCHAN);
}
return f;
}