Module Name: src Committed By: martin Date: Sun Dec 10 13:09:58 UTC 2023
Modified Files: src/lib/libc/net [netbsd-9]: sethostent.c Log Message: Pull up following revision(s) (requested by kre in ticket #1776): lib/libc/net/sethostent.c: revision 1.21 Fix a couple of (not very likely) memory leaks, reported by e...@google.com who attributed them: the malloc one was reported to Android (as https://android-review.googlesource.com/c/platform/bionic/+/2856549) by wuhaitao3 <wuhait...@xiaomi.corp-partner.google.com>; Chris Ferris <cfer...@google.com> then spotted the goto nospc one. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.20.28.1 src/lib/libc/net/sethostent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/net/sethostent.c diff -u src/lib/libc/net/sethostent.c:1.20 src/lib/libc/net/sethostent.c:1.20.28.1 --- src/lib/libc/net/sethostent.c:1.20 Mon Mar 17 13:24:23 2014 +++ src/lib/libc/net/sethostent.c Sun Dec 10 13:09:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $ */ +/* $NetBSD: sethostent.c,v 1.20.28.1 2023/12/10 13:09:58 martin 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.20 2014/03/17 13:24:23 christos Exp $"); +__RCSID("$NetBSD: sethostent.c,v 1.20.28.1 2023/12/10 13:09:58 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -171,6 +171,7 @@ _hf_gethtbyname2(const char *name, int a } if ((ptr = buf = malloc(len = info->buflen)) == NULL) { + endhostent_r(&hf); *info->he = NETDB_INTERNAL; return NULL; } @@ -251,6 +252,7 @@ _hf_gethtbyname2(const char *name, int a free(buf); return hp; nospc: + endhostent_r(&hf); *info->he = NETDB_INTERNAL; free(buf); errno = ENOSPC;