This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1318] New: Memory leak in _nl_load_locale_from_archive
- From: "jsnajdr at kerio dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 9 Sep 2005 15:44:52 -0000
- Subject: [Bug libc/1318] New: Memory leak in _nl_load_locale_from_archive
- Reply-to: sourceware-bugzilla at sourceware dot org
There is a memory leak in locale/loadarchive.c.
Function _nl_load_locale_from_archive allocates a string:
const char *normalized_codeset = _nl_normalize_codeset (p, rest - p);
Then it uses it in a conditional:
if (strncmp (normalized_codeset, p, rest - p) != 0
|| normalized_codeset[rest - p] != '\0')
If this conditional is true, something is done and the normalized_codeset is freed.
Otherwise, nothing is done, not even a free().
We found this leak when running our program in valgrind:
==32632== 4135 bytes in 827 blocks are definitely lost in loss record 280 of 390
==32632== at 0x1B9018D9: malloc (vg_replace_malloc.c:149)
==32632== by 0x1BAD01BA: _nl_normalize_codeset (in /lib/i686/libc.so.6)
==32632== by 0x1BACA2A6: _nl_load_locale_from_archive (in /lib/i686/libc.so.6)
==32632== by 0x1BAC95A0: _nl_find_locale (in /lib/i686/libc.so.6)
==32632== by 0x1BACB44F: newlocale (in /lib/i686/libc.so.6)
==32632== by 0x1BA5200B:
std::locale::facet::_S_create_c_locale(__locale_struct*&, char const*,
__locale_struct*) (in /usr/lib/libstdc++.so.5.0.5)
==32632== by 0x1BA3126F: std::locale::_Impl::_Impl(char const*, unsigned) (in
/usr/lib/libstdc++.so.5.0.5)
==32632== by 0x1BA0D6C5: std::locale::locale(char const*) (in
/usr/lib/libstdc++.so.5.0.5)
--
Summary: Memory leak in _nl_load_locale_from_archive
Product: glibc
Version: 2.3.5
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: jsnajdr at kerio dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=1318
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.