layers: Added return check for freeMemObjInfo call
authorMark Mueller <markm@lunarg.com>
Mon, 11 Jul 2016 21:03:44 +0000 (15:03 -0600)
committerMark Mueller <markm@lunarg.com>
Tue, 12 Jul 2016 15:09:15 +0000 (09:09 -0600)
In FreeMemory, the return value of freeMemObjInfo was
being ignored, which incorrectly allowed calls which
failed validation to still be passed to lower levels.
This change corrects that.

Change-Id: Iddbffad22f9502061441e961daef2e7fa26a5fcf

layers/core_validation.cpp

index cd804b8..e3ed21b 100644 (file)
@@ -4760,11 +4760,13 @@ FreeMemory(VkDevice device, VkDeviceMemory mem, const VkAllocationCallbacks *pAl
     // undefined behavior.
 
     std::unique_lock<std::mutex> lock(global_lock);
-    freeMemObjInfo(my_data, device, mem, false);
+    bool skip_call = freeMemObjInfo(my_data, device, mem, false);
     print_mem_list(my_data);
     printCBList(my_data);
     lock.unlock();
-    my_data->device_dispatch_table->FreeMemory(device, mem, pAllocator);
+    if (!skip_call) {
+        my_data->device_dispatch_table->FreeMemory(device, mem, pAllocator);
+    }
 }
 
 static bool validateMemRange(layer_data *my_data, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size) {