Source-Changes-HG archive

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

[src/trunk]: src/lib Fix fdleak in error case. Found by cppcheck.



details:   https://anonhg.NetBSD.org/src/rev/e75a50145c95
branches:  trunk
changeset: 760439:e75a50145c95
user:      wiz <wiz%NetBSD.org@localhost>
date:      Wed Jan 05 00:09:43 2011 +0000

description:
Fix fdleak in error case. Found by cppcheck.

diffstat:

 lib/libc/net/hesiod.c      |  5 +++--
 lib/librumpuser/rumpuser.c |  5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r cb7d2aab1470 -r e75a50145c95 lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c     Wed Jan 05 00:03:52 2011 +0000
+++ b/lib/libc/net/hesiod.c     Wed Jan 05 00:09:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hesiod.c,v 1.24 2005/10/19 22:56:42 christos Exp $     */
+/*     $NetBSD: hesiod.c,v 1.25 2011/01/05 00:09:43 wiz Exp $  */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -51,7 +51,7 @@
     "#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
 __IDSTRING(rcsid_hescompat_c,
     "#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
-__RCSID("$NetBSD: hesiod.c,v 1.24 2005/10/19 22:56:42 christos Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.25 2011/01/05 00:09:43 wiz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -378,6 +378,7 @@
                        *which = strdup(data);
                        if (!*which) {
                                errno = ENOMEM;
+                               (void)fclose(fp);
                                return -1;
                        }
                } else {
diff -r cb7d2aab1470 -r e75a50145c95 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c        Wed Jan 05 00:03:52 2011 +0000
+++ b/lib/librumpuser/rumpuser.c        Wed Jan 05 00:09:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.10 2010/11/15 15:23:32 pooka Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.11 2011/01/05 00:19:20 wiz Exp $        */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.10 2010/11/15 15:23:32 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.11 2011/01/05 00:19:20 wiz Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -159,6 +159,7 @@
 
                if (ioctl(fd, DIOCGDINFO, &lab) == -1) {
                        seterror(errno);
+                       (void)close(fd);
                        rv = -1;
                        goto out;
                }



Home | Main Index | Thread Index | Old Index