e24a3ce
From 12e1284a67e5e3404c704c3f864749fd9f04c7c4 Mon Sep 17 00:00:00 2001
e24a3ce
From: Tony Cook <tony@develop-help.com>
e24a3ce
Date: Wed, 7 Aug 2019 14:58:14 +1000
e24a3ce
Subject: [PATCH] PerlIO::Via: check arg is non-NULL before using it.
e24a3ce
MIME-Version: 1.0
e24a3ce
Content-Type: text/plain; charset=UTF-8
e24a3ce
Content-Transfer-Encoding: 8bit
e24a3ce
e24a3ce
I can't find any code in core that ends up calling the _pushed handler
e24a3ce
with arg == NULL, but PerlIO_push() is API, and there might be
e24a3ce
CPAN or DarkPAN code out there that does, escpecially since there's
e24a3ce
a check for arg being non-NULL further down.
e24a3ce
e24a3ce
CID 169261.
e24a3ce
e24a3ce
Signed-off-by: Petr Písař <ppisar@redhat.com>
e24a3ce
---
e24a3ce
 ext/PerlIO-via/via.xs | 4 ++--
e24a3ce
 1 file changed, 2 insertions(+), 2 deletions(-)
e24a3ce
e24a3ce
diff --git a/ext/PerlIO-via/via.xs b/ext/PerlIO-via/via.xs
e24a3ce
index d91c6855fc..8456242bc0 100644
e24a3ce
--- a/ext/PerlIO-via/via.xs
e24a3ce
+++ b/ext/PerlIO-via/via.xs
e24a3ce
@@ -134,8 +134,8 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
e24a3ce
 {
e24a3ce
     IV code = PerlIOBase_pushed(aTHX_ f, mode, Nullsv, tab);
e24a3ce
 
e24a3ce
-    if (SvTYPE(arg) >= SVt_PVMG
e24a3ce
-		&& mg_findext(arg, PERL_MAGIC_ext, &PerlIOVia_tag)) {
e24a3ce
+    if (arg && SvTYPE(arg) >= SVt_PVMG
e24a3ce
+        && mg_findext(arg, PERL_MAGIC_ext, &PerlIOVia_tag)) {
e24a3ce
 	return code;
e24a3ce
     }
e24a3ce
 
e24a3ce
-- 
e24a3ce
2.21.0
e24a3ce