Revert the double-free bug that I introduced in
2019-03-11T15:20:54Z!eggert@cs.ucla.edu.
* src/pdumper.c (dump_mmap_reset): Do not free the private member;
that’s the release function’s job.
(dump_mm_heap_cb_release): Free cb if its refcount goes to zero.
(dump_mmap_contiguous_heap): Mention memory leak in comment.
{
map->mapping = NULL;
map->release = NULL;
- void *private = map->private;
map->private = NULL;
- free (private);
}
static void
{
eassert (cb->refcount > 0);
if (--cb->refcount == 0)
- free (cb->mem);
+ {
+ free (cb->mem);
+ free (cb);
+ }
}
static void
size_t total_size)
{
bool ret = false;
+
+ /* FIXME: This storage sometimes is never freed.
+ Beware: the simple patch 2019-03-11T15:20:54Z!eggert@cs.ucla.edu
+ is worse, as it sometimes frees this storage twice. */
struct dump_memory_map_heap_control_block *cb = calloc (1, sizeof (*cb));
+
char *mem;
if (!cb)
goto out;