From 3b5017cc0e054db441068d0bf45a69cdff68bcf8 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Fri, 22 Feb 2013 16:38:22 +0000 Subject: [PATCH] Validate that the pointer passed to wmem_free is valid when using the simple allocator. Thanks to Bill Meier for suggesting this. svn path=/trunk/; revision=47815 --- epan/wmem/wmem_allocator_simple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epan/wmem/wmem_allocator_simple.c b/epan/wmem/wmem_allocator_simple.c index 0ec429da4e..0a717a2c29 100644 --- a/epan/wmem/wmem_allocator_simple.c +++ b/epan/wmem/wmem_allocator_simple.c @@ -58,13 +58,15 @@ wmem_simple_alloc(void *private_data, const size_t size) static void wmem_simple_free(void *private_data, void *ptr) { + gboolean removed = FALSE; wmem_simple_allocator_t *allocator; allocator = (wmem_simple_allocator_t*) private_data; /* remove() takes care of calling g_free() for us since we set up the * hash table with g_hash_table_new_full() */ - g_hash_table_remove(allocator->block_table, ptr); + removed = g_hash_table_remove(allocator->block_table, ptr); + g_assert(removed); } static void *