Revision: 58711
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58711
Author:   nazgul
Date:     2013-07-29 06:49:18 +0000 (Mon, 29 Jul 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenlib/intern/BLI_mempool.c

Modified: 
branches/soc-2013-depsgraph_mt/source/blender/blenlib/intern/BLI_mempool.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenlib/intern/BLI_mempool.c  
2013-07-29 06:49:11 UTC (rev 58710)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenlib/intern/BLI_mempool.c  
2013-07-29 06:49:18 UTC (rev 58711)
@@ -258,6 +258,22 @@
 {
        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 */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to