Change scope of validationExt and validationLayerName variables

Pointer to a variable declared into a block statement is stored and used outside of the block by vkCreateInstance. This can lead to segmentation fault.
Move the declaration of validationExt/validationLayerName outside of the block to fix the crash.
This commit is contained in:
jeromenxp 2021-01-18 17:41:41 +01:00
parent 334692a6ef
commit 1b22456d07
3 changed files with 6 additions and 5 deletions

View file

@ -95,11 +95,12 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
}
// The VK_LAYER_KHRONOS_validation contains all current validation functionality.
// Note that on Android this layer requires at least NDK r20
const char* validationLayerName = "VK_LAYER_KHRONOS_validation";
if (settings.validation)
{
// The VK_LAYER_KHRONOS_validation contains all current validation functionality.
// Note that on Android this layer requires at least NDK r20
const char* validationLayerName = "VK_LAYER_KHRONOS_validation";
// Check if this layer is available at instance level
uint32_t instanceLayerCount;
vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr);