summaryrefslogtreecommitdiff
path: root/src/modules/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2013-01-24 02:44:14 +0000
committerCedric BAIL <cedric.bail@free.fr>2013-01-24 02:44:14 +0000
commitb1d856bc8b69e69b41e235cc51235cb9505307ce (patch)
tree5c2a0e6bce3426a1e88be46bcf1af46814b9282a /src/modules/eina
parent3cfd345a91b5c5708cb48ed9c0f0038ab72628fa (diff)
efl/eina: detect when freeing pointer inside an allocated memory.
SVN revision: 83195
Diffstat (limited to 'src/modules/eina')
-rw-r--r--src/modules/eina/mp/chained_pool/eina_chained_mempool.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
index 869633afd9..2da74adb28 100644
--- a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
+++ b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
@@ -211,14 +211,22 @@ _eina_chained_mempool_free_in(Chained_Mempool *pool, Chained_Pool *p, void *ptr)
211 // pool mem base 211 // pool mem base
212 pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool)); 212 pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
213 213
214#ifdef DEBUG
214 // is it in pool mem? 215 // is it in pool mem?
215 if (ptr < pmem) 216 if (ptr < pmem)
216 { 217 {
217#ifdef DEBUG 218 INF("%p is inside the private part of %p pool from %p '%s' Chained_Mempool (could be the sign of a buffer underrun).", ptr, p, pool, pool->name);
218 INF("%p is inside the private part of %p pool from %p Chained_Mempool (could be the sign of a buffer underrun).", ptr, p, pool); 219 return EINA_FALSE;
219#endif 220 }
221
222 // is it really a pointer returned by malloc
223 if ((((unsigned char *)ptr) - (unsigned char *)(p + 1)) % pool->item_alloc)
224 {
225 INF("%p is %i bytes inside a pointer served by %p '%s' Chained_Mempool (You are freeing the wrong pointer man !). %i",
226 ptr, ((((unsigned char *)ptr) - (unsigned char *)(p + 1)) % pool->item_alloc), pool, pool->name);
220 return EINA_FALSE; 227 return EINA_FALSE;
221 } 228 }
229#endif
222 230
223 // freed node points to prev free node 231 // freed node points to prev free node
224 eina_trash_push(&p->base, ptr); 232 eina_trash_push(&p->base, ptr);