summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/api.cpp
diff options
context:
space:
mode:
authorCourtney Goeltzenleuchter <courtneygo@google.com>2016-12-29 08:46:18 -0700
committerCourtney Goeltzenleuchter <courtneygo@google.com>2016-12-29 09:34:59 -0700
commit1531bf11e3ea065137562ce29e07ee5e40f3bacc (patch)
treed9c406404181df0254027a0292765185ac0aef8b /vulkan/libvulkan/api.cpp
parent02400591d3f61ec73fd959f2977f496124df708e (diff)
vulkan: Correct access after free issue
While testing argument validation in the loader, I found that I got SEGFAULTs trying to access the logger class created in LayerChain::CreateDevice. I believe that the logger object was being destroyed at the end of the LayerChain construction statement so that a reference to the logger caused a SEGFAULT. Fix CreateInstance path as well, though the loader doesn't currently call the logger in that path, so no way to verify. Test: run vkCreateDevice_test on Vulkan device. See tests/README.md for details Bug: 33783620 Change-Id: Ib46023e8a8dfa008510c655c5b216aabaaf2ea83
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r--vulkan/libvulkan/api.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 4d30bbb965..f5daca7020 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -1049,7 +1049,8 @@ VkBool32 LayerChain::DebugReportCallback(VkDebugReportFlagsEXT flags,
VkResult LayerChain::CreateInstance(const VkInstanceCreateInfo* create_info,
const VkAllocationCallbacks* allocator,
VkInstance* instance_out) {
- LayerChain chain(true, driver::DebugReportLogger(*create_info),
+ const driver::DebugReportLogger logger(*create_info);
+ LayerChain chain(true, logger,
(allocator) ? *allocator : driver::GetDefaultAllocator());
VkResult result = chain.ActivateLayers(create_info->ppEnabledLayerNames,
@@ -1074,8 +1075,9 @@ VkResult LayerChain::CreateDevice(VkPhysicalDevice physical_dev,
const VkDeviceCreateInfo* create_info,
const VkAllocationCallbacks* allocator,
VkDevice* dev_out) {
+ const driver::DebugReportLogger logger = driver::Logger(physical_dev);
LayerChain chain(
- false, driver::Logger(physical_dev),
+ false, logger,
(allocator) ? *allocator : driver::GetData(physical_dev).allocator);
VkResult result = chain.ActivateLayers(