layers: Fix memtracker segfault for ill-behaved apps
Freeing object memory before destroying object resulted in a segfault.
This is illegal but shouldn't crash the layer.
diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp
index a0f45bc..44fc5d9 100644
--- a/layers/mem_tracker.cpp
+++ b/layers/mem_tracker.cpp
@@ -430,6 +430,10 @@
/* TODO: Would be nice to return the actual object type */
log_msg(mdd(pMemObjInfo->object), VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, (*it), 0, MEMTRACK_NONE, "MEM",
"VK Object %p still has a reference to mem obj %p", (*it), pMemObjInfo->mem);
+
+ // Found an object referencing this memory, remove its pointer to this memobj
+ MT_OBJ_INFO *pObjInfo = get_object_info(*it);
+ pObjInfo->pMemObjInfo = NULL;
}
// Clear the list of hanging references
pMemObjInfo->pObjBindings.clear();