From: Father Chrysostomos Date: Tue, 24 Dec 2013 04:37:18 +0000 (-0800) Subject: pp_sys.c: Remove null checks from pp_sockpair X-Git-Tag: v5.19.8~231 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/49561e08a01a67f5fd863f1978b62a9b241d66b6 pp_sys.c: Remove null checks from pp_sockpair There is actually no way for nulls to reach this code. Nulls on the stack only happen with pp_coreargs, and only with ops that have optional arguments, of which socketpair is not one. GvIOn uses gv_add_by_type, which adds a new IO if there is not already one, so it will never return null if the GV is not null. --- diff --git a/pp_sys.c b/pp_sys.c index aba3b14..49122e6 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2415,27 +2415,17 @@ PP(pp_sockpair) const int protocol = POPi; const int type = POPi; const int domain = POPi; - GV * gv1; - IO * io1; GV * const gv2 = MUTABLE_GV(POPs); - IO * const io2 = gv2 ? GvIOn(gv2) : NULL; - if (!io2) - report_evil_fh(gv2); + IO * const io2 = GvIOn(gv2); + GV * const gv1 = MUTABLE_GV(POPs); + IO * const io1 = GvIOn(gv1); - gv1 = MUTABLE_GV(POPs); - io1 = gv1 ? GvIOn(gv1) : NULL; - if (!io1) - report_evil_fh(gv1); - - if (io1 && IoIFP(io1)) + if (IoIFP(io1)) do_close(gv1, FALSE); - if (io2 && IoIFP(io2)) + if (IoIFP(io2)) do_close(gv2, FALSE); - if (!io1 || !io2) - RETPUSHUNDEF; - TAINT_PROPER("socketpair"); if (PerlSock_socketpair(domain, type, protocol, fd) < 0) RETPUSHUNDEF;