symisc / unqlite

An Embedded NoSQL, Transactional Database Engine
https://unqlite.symisc.net
Other
2.11k stars 164 forks source link

unqlite: fix the memory leak about cell table #164

Open CV-Bowen opened 9 months ago

CV-Bowen commented 9 months ago

Page cell table is alloced in lhInstallCell() when pPage->nCell < 1, but not free the cell table when pPage->nCell == 0.

So when in the next call of lhInstallCell() and pPage->nCell == 0, cell table is mallcoed again and old cell table not freed. Memory leak happends.

Memory Leak Backtrace:

malloc at nuttx/mm/umm_heap/umm_malloc.c:64
SyOSHeapAlloc atexternal/unqlite/unqlite/unqlite.c:26906
 (inlined by) MemOSAlloc at external/unqlite/unqlite/unqlite.c:27095
MemBackendAlloc at external/unqlite/unqlite/unqlite.c:27149
SyMemBackendAlloc at external/unqlite/unqlite/unqlite.c:27179
(discriminator 3) lhInstallCell at external/unqlite/unqlite/unqlite.c:49029
lhStoreCell at external/unqlite/unqlite/unqlite.c:50741
lhRecordInstall at external/unqlite/unqlite/unqlite.c:51065
 (inlined by) lh_record_insert at external/unqlite/unqlite/unqlite.c:51156
lh_record_insert at external/unqlite/unqlite/unqlite.c:51103
 (inlined by) lhash_kv_replace at external/unqlite/unqlite/unqlite.c:51184
CV-Bowen commented 9 months ago

@symisc I found a memory leak problem. Could take a look? Thanks.

CV-Bowen commented 3 months ago

@symisc Hi, Could you take a look at this memory leak issue?