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
This commit is contained in:
Evan Huus 2013-02-22 16:38:22 +00:00
parent 2f791fb573
commit 3b5017cc0e
1 changed files with 3 additions and 1 deletions

View File

@ -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 *