Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/net fix memory leak



details:   https://anonhg.NetBSD.org/src/rev/6b61dc0a7b89
branches:  trunk
changeset: 794557:6b61dc0a7b89
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 17 13:24:23 2014 +0000

description:
fix memory leak
XXX: pullup 6

diffstat:

 lib/libc/net/sethostent.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 11208db36db7 -r 6b61dc0a7b89 lib/libc/net/sethostent.c
--- a/lib/libc/net/sethostent.c Mon Mar 17 11:30:40 2014 +0000
+++ b/lib/libc/net/sethostent.c Mon Mar 17 13:24:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sethostent.c,v 1.19 2013/08/27 09:56:12 christos Exp $ */
+/*     $NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $ */
 
 /*
  * Copyright (c) 1985, 1993
@@ -35,7 +35,7 @@
 static char sccsid[] = "@(#)sethostent.c       8.1 (Berkeley) 6/4/93";
 static char rcsid[] = "Id: sethostent.c,v 8.5 1996/09/28 06:51:07 vixie Exp ";
 #else
-__RCSID("$NetBSD: sethostent.c,v 1.19 2013/08/27 09:56:12 christos Exp $");
+__RCSID("$NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -223,6 +223,7 @@
 
        if (num == 0) {
                *info->he = HOST_NOT_FOUND;
+               free(buf);
                return NULL;
        }
 
@@ -247,9 +248,11 @@
                HENT_SCOPY(hp->h_aliases[i], aliases[i], ptr, len);
        hp->h_aliases[anum] = NULL;
 
+       free(buf);
        return hp;
 nospc:
        *info->he = NETDB_INTERNAL;
+       free(buf);
        errno = ENOSPC;
        return NULL;
 }



Home | Main Index | Thread Index | Old Index