Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi/dist/ipc CID 1132757: Check error return



details:   https://anonhg.NetBSD.org/src/rev/c392e754d7c1
branches:  trunk
changeset: 791673:c392e754d7c1
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 27 20:52:24 2013 +0000

description:
CID 1132757: Check error return

diffstat:

 external/bsd/nvi/dist/ipc/ipc_method.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 8d85e7463748 -r c392e754d7c1 external/bsd/nvi/dist/ipc/ipc_method.c
--- a/external/bsd/nvi/dist/ipc/ipc_method.c    Wed Nov 27 20:50:45 2013 +0000
+++ b/external/bsd/nvi/dist/ipc/ipc_method.c    Wed Nov 27 20:52:24 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipc_method.c,v 1.5 2013/11/27 20:50:45 christos Exp $  */
+/*     $NetBSD: ipc_method.c,v 1.6 2013/11/27 20:52:24 christos Exp $  */
 /*-
  * Copyright (c) 1996
  *     Rob Zimmermann.  All rights reserved.
@@ -110,7 +110,8 @@
        ch.header.cmsg_len = sizeof(ch);
 
        *(int *)CMSG_DATA(&ch.header) = sockets[1];
-       sendmsg(ipvi->ofd, &mh, 0);
+       if (sendmsg(ipvi->ofd, &mh, 0) == -1)
+               goto alloc_err;
        dummy = (fd == -1) ? ' ' : 'F';
        *(int *)CMSG_DATA(&ch.header) = sockets[1];
        sendmsg(sockets[0], &mh, 0);
@@ -118,7 +119,8 @@
 
        if (fd != -1) {
                *(int *)CMSG_DATA(&ch.header) = fd;
-               sendmsg(sockets[0], &mh, 0);
+               if (sendmsg(sockets[0], &mh, 0) == -1)
+                       goto alloc_err;
                close(fd);
        }
 
@@ -155,6 +157,8 @@
        return 0;
 
 alloc_err:
+       if (fd != -1)
+               close(fd);
        return 1;
 }
 



Home | Main Index | Thread Index | Old Index