This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_sys.c: some Coverity findings: NULL guards for io pointers
authorJarkko Hietaniemi <jhi@iki.fi>
Sat, 8 Apr 2006 18:52:32 +0000 (21:52 +0300)
committerNicholas Clark <nick@ccl4.org>
Mon, 10 Apr 2006 11:56:21 +0000 (11:56 +0000)
Message-Id: <20060408155232.4C9726D08C@ugli.hut.fi>
Date: Sat,  8 Apr 2006 18:52:32 +0300 (EEST)

p4raw-id: //depot/perl@27755

pp_sys.c

index 7a3dbc7..1db57b0 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2276,7 +2276,7 @@ PP(pp_socket)
     if (!gv || !io) {
        if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
            report_evil_fh(gv, io, PL_op->op_type);
     if (!gv || !io) {
        if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
            report_evil_fh(gv, io, PL_op->op_type);
-       if (IoIFP(io))
+       if (io && IoIFP(io))
            do_close(gv, FALSE);
        SETERRNO(EBADF,LIB_INVARG);
        RETPUSHUNDEF;
            do_close(gv, FALSE);
        SETERRNO(EBADF,LIB_INVARG);
        RETPUSHUNDEF;
@@ -2332,9 +2332,9 @@ PP(pp_sockpair)
            if (!gv2 || !io2)
                report_evil_fh(gv1, io2, PL_op->op_type);
        }
            if (!gv2 || !io2)
                report_evil_fh(gv1, io2, PL_op->op_type);
        }
-       if (IoIFP(io1))
+       if (io1 && IoIFP(io1))
            do_close(gv1, FALSE);
            do_close(gv1, FALSE);
-       if (IoIFP(io2))
+       if (io2 && IoIFP(io2))
            do_close(gv2, FALSE);
        RETPUSHUNDEF;
     }
            do_close(gv2, FALSE);
        RETPUSHUNDEF;
     }