layers: Only save p-devices if call was successful
Change-Id: Ife211b1b2dc97c5bab0d6e7b177ead6b1a6105d3
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 3b73f27..0030793 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -11238,7 +11238,7 @@
my_data->instance_dispatch_table->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
if (NULL == pPhysicalDevices) {
my_data->instance_state->physical_devices_count = *pPhysicalDeviceCount;
- } else { // Save physical devices
+ } else if (result == VK_SUCCESS){ // Save physical devices
for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) {
layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(pPhysicalDevices[i]), layer_data_map);
phy_dev_data->physical_device_state = unique_ptr<PHYSICAL_DEVICE_STATE>(new PHYSICAL_DEVICE_STATE());