From d1c7d64c2c3a88bf0a8848e2338233397efd5ab0 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 2 May 2012 12:10:55 +0200 Subject: [PATCH] Delete Sliced_heap::Block object when freeing. When a portion of the sliced heap gets freed, the corresponding block gets removed from the list of blocks, and it's dataspace containing the block gets detached, but it's destructor never gets called. This leads to leaking capabilities, when Native_capability is implemented as smart-pointer, because the destructor of Ram_dataspace_capability that is part of the Block object gets never called. --- base/src/base/heap/sliced_heap.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/src/base/heap/sliced_heap.cc b/base/src/base/heap/sliced_heap.cc index 67580da036..a05b06cf89 100644 --- a/base/src/base/heap/sliced_heap.cc +++ b/base/src/base/heap/sliced_heap.cc @@ -29,6 +29,8 @@ namespace Genode { inline void *operator new(size_t size, void *at_addr) { return at_addr; } + inline void operator delete (void*) { } + /** * Constructor */ @@ -106,6 +108,7 @@ void Sliced_heap::free(void *addr, size_t size) _block_list.remove(b); _consumed -= b->size(); Ram_dataspace_capability ds_cap = b->ds_cap(); + delete b; _rm_session->detach(b); _ram_session->free(ds_cap); }