From 32ad894f61e2a40596b88f1b01b3e4cecb49740a Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Tue, 25 Nov 2014 12:27:38 -0700 Subject: [PATCH] layers: Fix bug in DestroyObject code of MemTracker layer. --- layers/mem_tracker.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/layers/mem_tracker.c b/layers/mem_tracker.c index 9cf7e93..e4ebaae 100644 --- a/layers/mem_tracker.c +++ b/layers/mem_tracker.c @@ -1280,7 +1280,15 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerImage(XGL_DEVICE device, const XGL XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) { // TODO : Verify that no memory is bound to this object at time of destruction - GLOBAL_OBJECT_NODE* pTrav = getGlobalObjectNode(object); + GLOBAL_OBJECT_NODE* pTrav = pGlobalObjectHead; + GLOBAL_OBJECT_NODE* pPrev = pTrav; + // First locate node in global list along with prev node + while (pTrav) { + if (object == pTrav->object) + break; + pPrev = pTrav; + pTrav = pTrav->pNext; + } if (pTrav) { if (pTrav->pMemNode) { char str[1024]; @@ -1291,7 +1299,8 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) } if (pGlobalObjectHead == pTrav) // update HEAD if needed pGlobalObjectHead = pTrav->pNext; - // Delete the obj node + // Delete the obj node from global list + pPrev->pNext = pTrav->pNext; free(pTrav); } XGL_RESULT result = nextTable.DestroyObject(object); -- 2.7.4