This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
glibc - catopen has small memory leak
- From: "Salina Chu" <salina at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Cc: "Mark Brown" <bmark at us dot ibm dot com>, "Khoa Huynh" <khoa at us dot ibm dot com>, mmaass at us dot ibm dot com
- Date: Mon, 6 May 2002 13:41:36 -0500
- Subject: glibc - catopen has small memory leak
- Sensitivity:
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;
}