diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-19 14:18:25 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-19 14:18:25 +0400 |
commit | bec9bcc14c4e763b8f82d22dd7e1741b40155b3c (patch) | |
tree | 60731a9e631d4963d2b7a429a8dbaa66b579765f /source/blender/blenlib | |
parent | 552d068565172a2b7eaa538cb1c343e098715e4e (diff) |
Added check for address being freed by mempool free
When blender is built in debug mode, BLI_mempool_free will
ensure address passed to the function actually belongs to
this pool.
--
svn merge -r58710:58711 ^/branches/soc-2013-depsgraph_mt
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index bb326a23d59..ea63dd81ab2 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -258,6 +258,22 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) { BLI_freenode *newhead = addr; +#ifndef NDEBUG + { + BLI_mempool_chunk *chunk; + bool found = false; + for (chunk = pool->chunks.first; chunk; chunk = chunk->next) { + if ((char*)addr >= (char*)chunk->data && (char*)addr < (char*)chunk->data + pool->csize) { + found = true; + break; + } + } + if (!found) { + BLI_assert(!"Attempt to free data which is not in pool.\n"); + } + } +#endif + if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { #ifndef NDEBUG /* this will detect double free's */ |