aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-01-20 02:47:58 +0000
committerEvan Huus <eapache@gmail.com>2013-01-20 02:47:58 +0000
commitf3ba854bec2939b46d53b1e464c6508e2384246d (patch)
treecf80e18cfc5fc6296970d990acc0adefb5ee772f /epan
parent8df0020ac6fe236a4200664b023fa68ddef1abdd (diff)
NULL is also a valid return for g_malloc if the requested size is 0.
svn path=/trunk/; revision=47172
Diffstat (limited to 'epan')
-rw-r--r--epan/wmem/wmem_allocator_simple.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/epan/wmem/wmem_allocator_simple.c b/epan/wmem/wmem_allocator_simple.c
index 38c43e0fd8..d86219bd4f 100644
--- a/epan/wmem/wmem_allocator_simple.c
+++ b/epan/wmem/wmem_allocator_simple.c
@@ -50,7 +50,11 @@ wmem_simple_alloc(void *private_data, const size_t size)
buf = g_malloc(size);
- g_hash_table_insert(allocator->block_table, buf, buf);
+ /* alloc is allowed to return NULL if the requested size is 0, in
+ * which case we don't need to add it to the hash table */
+ if (buf) {
+ g_hash_table_insert(allocator->block_table, buf, buf);
+ }
return buf;
}
@@ -71,7 +75,7 @@ wmem_simple_realloc(void *private_data, void *ptr, const size_t size)
* block, and remove()ing it would call g_free() which we don't want. */
g_hash_table_steal(allocator->block_table, ptr);
/* realloc is allowed to return NULL if the requested size is 0, in
- * which case we don't want to add back to the hash table */
+ * which case we don't need to add it to the hash table */
if (newptr) {
g_hash_table_insert(allocator->block_table, newptr, newptr);
}