layers: Add null checks to RetireWorkOnQueue
authorMark Lobodzinski <mark@lunarg.com>
Fri, 11 Nov 2016 22:27:12 +0000 (15:27 -0700)
committerMark Lobodzinski <mark@lunarg.com>
Mon, 14 Nov 2016 15:10:09 +0000 (08:10 -0700)
API misuse was causing invalid object dereferences and crashes.

Change-Id: I81ff28b029b984a106a6c60063810e61a07cb945

layers/core_validation.cpp

index 09d41a9..32e9f90 100644 (file)
@@ -4754,18 +4754,25 @@ static bool RetireWorkOnQueue(layer_data *dev_data, QUEUE_NODE *pQueue, uint64_t
 
         for (auto & wait : submission.waitSemaphores) {
             auto pSemaphore = getSemaphoreNode(dev_data, wait.semaphore);
-            pSemaphore->in_use.fetch_sub(1);
+            if (pSemaphore) {
+                pSemaphore->in_use.fetch_sub(1);
+            }
             auto & lastSeq = otherQueueSeqs[wait.queue];
             lastSeq = std::max(lastSeq, wait.seq);
         }
 
         for (auto & semaphore : submission.signalSemaphores) {
             auto pSemaphore = getSemaphoreNode(dev_data, semaphore);
-            pSemaphore->in_use.fetch_sub(1);
+            if (pSemaphore) {
+                pSemaphore->in_use.fetch_sub(1);
+            }
         }
 
         for (auto cb : submission.cbs) {
             auto cb_node = getCBNode(dev_data, cb);
+            if (!cb_node) {
+                continue;
+            }
             // First perform decrement on general case bound objects
             DecrementBoundResources(dev_data, cb_node);
             for (auto drawDataElement : cb_node->drawData) {