This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A new patch for NIS+ memory leak


> 
> 
> Hello,
> 
> On Tue, May 04, H.J. Lu wrote:
> 
> > Hi,
> > 
> > This patch patch fixes some, not all, memory leaks in NIS code. The
> 
> It's the NIS+ code, not NIS. I would really wonder if you find a memory
> leak in NIS, but I don't wonder if you find one in NIS+.

Ooops. Sorry.

> 
> > Thorsten, could you please take a close look at my patch and other
> > possible memory leaks?
> 
> Yes, I will do it. In the moment I install my second Sparc at work, so I 
> could test it here.
> But the patch looks Ok.
> 

I believe this patch fixes all the NIS+ memory leaks seen by mountd.

Thanks.


H.J.
---
Wed May  5 09:28:20 1999  H.J. Lu  <hjl@gnu.org>

	* nis/nis_file.c (readColdStartFile): Allocate memory only
	after the file is opened successfully.
	
Tue May  4 18:38:22 1999  H.J. Lu  <hjl@gnu.org>

	* nis/nis_table.c (nis_list): Fix some meory leaks.

Index: nis/nis_file.c
===================================================================
RCS file: /work/cvs/gnu/glibc/nis/nis_file.c,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 nis_file.c
--- nis/nis_file.c	1998/07/29 23:54:45	1.1.1.7
+++ nis/nis_file.c	1999/05/05 16:24:43
@@ -31,14 +31,16 @@ readColdStartFile (void)
   XDR xdrs;
   FILE *in;
   bool_t status;
-  directory_obj *obj = calloc (1, sizeof (directory_obj));
+  directory_obj *obj;
 
-  if (obj == NULL)
-    return NULL;
-
   in = fopen (cold_start_file, "rb");
   if (in == NULL)
     return NULL;
+
+  obj = calloc (1, sizeof (directory_obj));
+  if (obj == NULL)
+    return NULL;
+
   xdrstdio_create (&xdrs, in, XDR_DECODE);
   status = _xdr_directory_obj (&xdrs, obj);
   xdr_destroy (&xdrs);
Index: nis/nis_table.c
===================================================================
RCS file: /work/cvs/gnu/glibc/nis/nis_table.c,v
retrieving revision 1.1.1.15
diff -u -p -r1.1.1.15 nis_table.c
--- nis/nis_table.c	1999/05/05 01:35:26	1.1.1.15
+++ nis/nis_table.c	1999/05/05 01:37:01
@@ -186,6 +186,7 @@ nis_list (const_nis_name name, unsigned 
       ibreq->ibr_name = NULL;
       if (names == NULL)
 	{
+	  nis_free_request (ibreq);
 	  NIS_RES_STATUS (res) = NIS_BADNAME;
 	  return res;
 	}
@@ -209,6 +210,7 @@ nis_list (const_nis_name name, unsigned 
       status = __nisfind_server (ibreq->ibr_name, &dir);
       if (status != NIS_SUCCESS)
         {
+	  nis_free_request (ibreq);
           NIS_RES_STATUS (res) = status;
           return res;
         }
@@ -227,6 +229,7 @@ nis_list (const_nis_name name, unsigned 
 	  {
 	    __nisbind_destroy (&bptr);
 	    nis_free_directory (dir);
+	    nis_free_request (ibreq);
 	    NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
 	    return res;
 	  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]