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
This commit is contained in:
@@ -258,6 +258,22 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
|
|||||||
{
|
{
|
||||||
BLI_freenode *newhead = 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) {
|
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
/* this will detect double free's */
|
/* this will detect double free's */
|
||||||
|
Reference in New Issue
Block a user