From c94cfed796feeae301ab2f26fc5fad7fb66e57a7 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 25 May 2006 01:20:21 +0000 Subject: [PATCH] Coverity CID 2282: Fix memory leak. --- usr.sbin/netgroup_mkdb/netgroup_mkdb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/netgroup_mkdb/netgroup_mkdb.c b/usr.sbin/netgroup_mkdb/netgroup_mkdb.c index a75ef5732e01..425560f4db77 100644 --- a/usr.sbin/netgroup_mkdb/netgroup_mkdb.c +++ b/usr.sbin/netgroup_mkdb/netgroup_mkdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: netgroup_mkdb.c,v 1.12 2002/07/20 08:40:18 grant Exp $ */ +/* $NetBSD: netgroup_mkdb.c,v 1.13 2006/05/25 01:20:21 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -32,7 +32,7 @@ */ #include #ifndef lint -__RCSID("$NetBSD: netgroup_mkdb.c,v 1.12 2002/07/20 08:40:18 grant Exp $"); +__RCSID("$NetBSD: netgroup_mkdb.c,v 1.13 2006/05/25 01:20:21 christos Exp $"); #endif #include @@ -486,13 +486,15 @@ ng_print(e, str) struct nentry *e; struct string *str; { - char *ptr = emalloc(e->n_size); + char *ptr; if (e->n_next == NULL) { str_append(str, "", ' '); return; } + ptr = emalloc(e->n_size); + for (e = e->n_next; e != NULL; e = e->n_next) { switch (e->n_type) { case _NG_NAME: