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