From owner-freebsd-bugs Tue May 16 8:50: 5 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id A882737B61A for ; Tue, 16 May 2000 08:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id IAA06407; Tue, 16 May 2000 08:50:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 16 May 2000 08:50:03 -0700 (PDT) Message-Id: <200005161550.IAA06407@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Tim Vanderhoek Subject: Re: bin/17084: memory leak in getcap.c (libc) Reply-To: Tim Vanderhoek Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/17084; it has been noted by GNATS. From: Tim Vanderhoek To: freebsd-gnats-submit@FreeBSD.org, vova@express.ru Cc: vanderh@ecf.toronto.edu Subject: Re: bin/17084: memory leak in getcap.c (libc) Date: Tue, 16 May 2000 11:44:41 -0400 (EDT) > >I have dip a bit into problem and found that memory leaks in >cgetent() called from login_getclassbyname() Will you please tell me if the following patch solves the problem. This patch solves what appear to be two memory leaks. There may be more memory leaks and which ones you run into may depend on your system's specific login.conf configuration. I can send you copies of the post-patched files to compile with your program if you'll find that easier. Please be sure to Cc: freebsd-gnats-submit@FreeBSD.org and don't change the Subject: line in your reply. Thanks. --- src/lib/libutil/~login_cap.c Tue May 16 11:26:03 2000 +++ src/lib/libutil/login_cap.c Tue May 16 11:26:19 2000 @@ -150,10 +150,11 @@ void login_close(login_cap_t * lc) { if (lc) { free(lc->lc_style); free(lc->lc_class); + free(lc->lc_cap); free(lc); if (--lc_object_count == 0) { free(internal_string); free(internal_array); internal_array = NULL; --- src/lib/libc/gen/~getcap.c Tue May 16 11:25:16 2000 +++ src/lib/libc/gen/getcap.c Tue May 16 11:39:29 2000 @@ -380,12 +380,14 @@ getent(cap, len, db_array, fd, name, dep } if (foundit) break; } - if (!foundit) + if (!foundit) { + free(record); return (-1); + } /* * Got the capability record, but now we have to expand all tc=name * references in it ... */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message