summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorLeon Timmermans <fawaka@gmail.com>2013-09-07 08:58:18 +0200
committerLeon Timmermans <fawaka@gmail.com>2013-09-07 09:01:42 +0200
commitdf8c7dee25da69fc88678b8949166e08fb686037 (patch)
tree8baedebddcab7691688e5439823133baa767a737 /perlio.c
parent7b6e8075e45ebc684565efbe3ce7b70435f20c79 (diff)
downloadperl-df8c7dee25da69fc88678b8949166e08fb686037.tar.gz
Fix segfault in filehandle duplication
Previously PerlIOBase_dup didn't check if pushing the new layer succeeded before (optionally) setting the utf8 flag. This could cause segfaults-by-nullpointer.
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/perlio.c b/perlio.c
index f7c0698c8c..7e6ceaef4d 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2309,7 +2309,7 @@ PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
if (self && self->Getarg)
arg = (*self->Getarg)(aTHX_ o, param, flags);
f = PerlIO_push(aTHX_ f, self, PerlIO_modestr(o,buf), arg);
- if (PerlIOBase(o)->flags & PERLIO_F_UTF8)
+ if (f && PerlIOBase(o)->flags & PERLIO_F_UTF8)
PerlIOBase(f)->flags |= PERLIO_F_UTF8;
SvREFCNT_dec(arg);
}