Fix bug in reallocation callback validation
authorPyry Haulos <phaulos@google.com>
Thu, 23 Feb 2017 22:11:27 +0000 (14:11 -0800)
committerPyry Haulos <phaulos@google.com>
Mon, 27 Feb 2017 16:17:55 +0000 (11:17 -0500)
vk::validateAllocationCallbacks() didn't correctly handle a case where
reallocate(NULL, size) returned previously seen pointer value.

VK-GL-CTS issue: 176
Components: Vulkan

Change-Id: I0822f8e4176d20d7bf296cd85f5c5223e189d250

external/vulkancts/framework/vulkan/vkAllocationCallbackUtil.cpp

index 9aaffe2aad71d3f984636e018df19abda970c94c..c5f03ee712b2f886ba0bf7cf1b0e098de83d9676 100644 (file)
@@ -482,9 +482,18 @@ void validateAllocationCallbacks (const AllocationCallbackRecorder& recorder, Al
 
                                        if (record.data.reallocation.returnedPtr)
                                        {
-                                               DE_ASSERT(!de::contains(ptrToSlotIndex, record.data.reallocation.returnedPtr));
-                                               ptrToSlotIndex[record.data.reallocation.returnedPtr] = allocations.size();
-                                               allocations.push_back(AllocationSlot(record, true));
+                                               if (!de::contains(ptrToSlotIndex, record.data.reallocation.returnedPtr))
+                                               {
+                                                       ptrToSlotIndex[record.data.reallocation.returnedPtr] = allocations.size();
+                                                       allocations.push_back(AllocationSlot(record, true));
+                                               }
+                                               else
+                                               {
+                                                       const size_t slotNdx = ptrToSlotIndex[record.data.reallocation.returnedPtr];
+                                                       DE_ASSERT(!allocations[slotNdx].isLive);
+                                                       allocations[slotNdx].isLive = true;
+                                                       allocations[slotNdx].record = record;
+                                               }
                                        }
                                }