In pp_sockpair, remove duplication of code to close the supplied file handles.
authorNicholas Clark <nick@ccl4.org>
Tue, 28 Dec 2010 08:32:44 +0000 (08:32 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 28 Dec 2010 08:32:44 +0000 (08:32 +0000)
It's not necessary to (also) test gv1 and gv2 before returning undef as an
error, because io1 will automatically be NULL if gv1 is NULL, and similarly
io2 if gv2 is.

pp_sys.c

index b2076cc..0d382ed 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2454,18 +2454,16 @@ PP(pp_sockpair)
            if (!gv2 || !io2)
                report_evil_fh(gv2, io2, PL_op->op_type);
        }
-       if (io1 && IoIFP(io1))
-           do_close(gv1, FALSE);
-       if (io2 && IoIFP(io2))
-           do_close(gv2, FALSE);
-       RETPUSHUNDEF;
     }
 
-    if (IoIFP(io1))
+    if (io1 && IoIFP(io1))
        do_close(gv1, FALSE);
-    if (IoIFP(io2))
+    if (io2 && IoIFP(io2))
        do_close(gv2, FALSE);
 
+    if (!io1 || !io2)
+       RETPUSHUNDEF;
+
     TAINT_PROPER("socketpair");
     if (PerlSock_socketpair(domain, type, protocol, fd) < 0)
        RETPUSHUNDEF;