Fix crash in RenderingDeviceVulkan::shader_create

This commit moves the declaration of a local variable to ensure its
scope survives long enough; at least in some versions of GCC and LLVM
the associated memory was freed too early and thus caused issues ranging
from black screens to crashes.
This commit is contained in:
rsjtdrjgfuzkfg 2020-10-25 00:56:54 +02:00
parent 6c173e2f7f
commit b1f95e150e

View file

@ -4312,8 +4312,10 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
}
pipeline_layout_create_info.pSetLayouts = layouts.ptr();
if (push_constant.push_constant_size) {
// Needs to be declared in this outer scope, otherwise it may not outlive its assignment
// to pipeline_layout_create_info.
VkPushConstantRange push_constant_range;
if (push_constant.push_constant_size) {
push_constant_range.stageFlags = push_constant.push_constants_vk_stage;
push_constant_range.offset = 0;
push_constant_range.size = push_constant.push_constant_size;