Merge vk-gl-cts/vulkan-cts-1.0.0 into vk-gl-cts/vulkan-cts-1.0.1
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / framework / vulkan / vkAllocationCallbackUtil.cpp
index 723706a..946c087 100644 (file)
@@ -390,7 +390,7 @@ void validateAllocationCallbacks (const AllocationCallbackRecorder& recorder, Al
                        case AllocationCallbackRecord::TYPE_ALLOCATION:
                        {
                                if (record.data.allocation.returnedPtr)
-                               { 
+                               {
                                        if (!de::contains(ptrToSlotIndex, record.data.allocation.returnedPtr))
                                        {
                                                ptrToSlotIndex[record.data.allocation.returnedPtr] = allocations.size();
@@ -399,7 +399,7 @@ void validateAllocationCallbacks (const AllocationCallbackRecorder& recorder, Al
                                        else
                                        {
                                                const size_t            slotNdx         = ptrToSlotIndex[record.data.allocation.returnedPtr];
-                                               if (!allocations[slotNdx].isLive) 
+                                               if (!allocations[slotNdx].isLive)
                                                {
                                                        allocations[slotNdx].isLive = true;
                                                        allocations[slotNdx].record = record;
@@ -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;
+                                               }
                                        }
                                }