Date: Tue, 16 May 2000 08:50:03 -0700 (PDT) From: Tim Vanderhoek <tim@localhost.nowhere> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/17084: memory leak in getcap.c (libc) Message-ID: <200005161550.IAA06407@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/17084; it has been noted by GNATS.
From: Tim Vanderhoek <tim@localhost.nowhere>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005161550.IAA06407>
