On Tue, Nov 23, 2004 at 05:17:26PM +0100, Christian Theune wrote:
> Hi,
>
> it looks like libmdb (0.6rc) has a memory leak. Valgrind told me this:
>
> ==1322== 3240 bytes in 9 blocks are definitely lost in loss record 23 of
> 27
> ==1322== at 0x1B905901: calloc (vg_replace_malloc.c:176)
> ==1322== by 0x1BFC1937: g_malloc0
> (in /usr/lib/libglib-2.0.so.0.400.7)
> ==1322== by 0x1B93EF9B: mdb_read_table (table.c:56)
>
> Does that make any sense to you?
table.c from line 56 is:
table = mdb_alloc_tabledef(entry);
mdb_read_pg(mdb, entry->table_pg);
if (mdb->pg_buf[0] != 0x02) return NULL; /* not a valid table def page */
[...]
mdb_alloc_tabledef() in mem.c calls g_malloc0().
So table.c does not free the allocated space if mdb->pg_buf[0]
is not 0x02.
The code is the same in current CVS.
Try this (untested):
--- mdbtools-0.6pre1.orig/src/libmdb/table.c 2004-06-15 06:12:37.000000000 +0200
+++ mdbtools-0.6pre1/src/libmdb/table.c 2004-11-24 11:26:52.000000000 +0200
@@ -56,7 +56,10 @@
table = mdb_alloc_tabledef(entry);
mdb_read_pg(mdb, entry->table_pg);
- if (mdb->pg_buf[0] != 0x02) return NULL; /* not a valid table def page */
+ if (mdb->pg_buf[0] != 0x02) {
+ mdb_free_tabledef(table);
+ return NULL; /* not a valid table def page */
+ }
len = mdb_pg_get_int16(mdb,8);
--
Michael Wood <mw...@ic...>
|