From aff1729a2c3e105d33047c9ad76da34aff0ca530 Mon Sep 17 00:00:00 2001 From: wiz Date: Wed, 5 Jan 2011 00:09:43 +0000 Subject: [PATCH] Fix fdleak in error case. Found by cppcheck. --- lib/libc/net/hesiod.c | 5 +++-- lib/librumpuser/rumpuser.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c index dd024e93c77b..2e7fb9827316 100644 --- a/lib/libc/net/hesiod.c +++ b/lib/libc/net/hesiod.c @@ -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 @@ __IDSTRING(rcsid_hesiod_p_h, "#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 @@ read_config_file(ctx, filename) *which = strdup(data); if (!*which) { errno = ENOMEM; + (void)fclose(fp); return -1; } } else { diff --git a/lib/librumpuser/rumpuser.c b/lib/librumpuser/rumpuser.c index 03e727a0d817..3d9d588cb660 100644 --- a/lib/librumpuser/rumpuser.c +++ b/lib/librumpuser/rumpuser.c @@ -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 #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 @@ rumpuser_getfileinfo(const char *path, uint64_t *sizep, int *ftp, int *error) if (ioctl(fd, DIOCGDINFO, &lab) == -1) { seterror(errno); + (void)close(fd); rv = -1; goto out; }