This is the mail archive of the libc-alpha@sources.redhat.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]
Other format: [Raw text]

glibc - catopen has small memory leak


IBM's cluster management team found this problem.
I am just reporting the problem / submitting patch on their behalf.

The catopen function in glibc-2.2.5 ( and 2.2.4 ) has a memory leak.
After allocating a buffer the internal catalog open function is called.
If this function returns an error,
e.g. the catalog does not exist, catopen returns (nl_catd)-1
without freeing the buffer.
The fix is simply to free the buffer before returning -1.

Salina Chu




2002-05-06  Michael A. Schmidt  <mmaass@us.ibm.com>
      * catgets/catgets.c ( catopen ): free buffer if internal
        catalog open fails


diff -Naur glibc-2.2.5/catgets/catgets.c glibc-2.2.5.new/catgets/catgets.c
--- glibc-2.2.5/catgets/catgets.c          Thu Aug  9 17:36:30 2001
+++ glibc-2.2.5.new/catgets/catgets.c            Wed May  1 14:31:55 2002
@@ -69,9 +69,11 @@
     /* We cannot get enough memory.  */
     return (nl_catd) -1;

-  if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
+  if (__open_catalog (cat_name, nlspath, env_var, result) != 0) {
     /* Couldn't open the file.  */
+    free ((void *) result);
     return (nl_catd) -1;
+  }

   return (nl_catd) result;
 }


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