VK: Fix memory corruption in VulkanExternalImageManager (#9116)

When calling setExternalSamplerVkSet the recycle
function lambda captured some variables allocated
on the stack, which are out of scope by the time
the function is called.

Change the capture to be done by value instead of
by ref to avoid this problem.
This commit is contained in:
rafadevai
2025-08-18 10:57:46 -07:00
committed by GitHub
parent bcea4ef75d
commit 55c65fb8a2

View File

@@ -191,9 +191,11 @@ void VulkanExternalImageManager::updateSetAndLayout(
VkDescriptorSet const srcSet = oldSet != VK_NULL_HANDLE ? oldSet : set->getVkSet();
copySet(mPlatform->getDevice(), srcSet, newSet, copyBindings);
set->setExternalSamplerVkSet(newSet, [&](VulkanDescriptorSet*) {
mDescriptorSetCache->manualRecycle(layout->count, newLayout, newSet);
});
set->setExternalSamplerVkSet(newSet,
[&descriptorSetCache = mDescriptorSetCache, layoutCount = layout->count, newLayout,
newSet](VulkanDescriptorSet*) {
descriptorSetCache->manualRecycle(layoutCount, newLayout, newSet);
});
if (oldLayout != newLayout) {
layout->setExternalSamplerVkLayout(newLayout);
}