glibc - catopen has small memory leak
Salina Chu
salina@us.ibm.com
Mon May 6 11:41:00 GMT 2002
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;
}
More information about the Libc-alpha
mailing list