Guardedalloc: Add extra logging and checks in MEM_freeN()
[blender-staging.git] / intern / guardedalloc / intern / mallocn_lockfree_impl.c
index eaa60202f3c01541f535989b58a29dbb0d0d742b..b5f3d1b15dc73e15b27d59bd650fec815ff123ec 100644 (file)
@@ -134,6 +134,14 @@ void MEM_lockfree_freeN(void *vmemh)
        MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
        size_t len = MEM_lockfree_allocN_len(vmemh);
 
+       if (vmemh == NULL) {
+               print_error("Attempt to free NULL pointer\n");
+#ifdef WITH_ASSERT_ABORT
+               abort();
+#endif
+               return;
+       }
+
        atomic_sub_u(&totblock, 1);
        atomic_sub_z(&mem_in_use, len);