From 48d510ac578c859ce2046f055d1e6dc37716a499 Mon Sep 17 00:00:00 2001 From: George Ouzounoudis Date: Thu, 10 Aug 2023 23:02:50 +0300 Subject: [PATCH] vulkan: Fix null pointer dereferencing on sample locations state In the case both sample locations and rasterization samples is supported by a driver as dynamic state, there is a case vk_multisample_sample_locations_state_init() does not fill ms->sample_locations at all. In this case we need to check this pointer when dereferencing it in vk_dynamic_graphics_state_init_ms(). Reviewed-by: Faith Ekstrand Reviewed-by: Mike Blumenkrantz Part-of: --- src/vulkan/runtime/vk_graphics_state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index d4f42c3083b..1b86e5a4d39 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -776,6 +776,9 @@ vk_multisample_sample_locations_state_init( ms->sample_locations = vk_standard_sample_locations_state(ms_info->rasterizationSamples); } + /* In the case that the rasterization samples are dynamic we cannot + * pre-populate with a specific set of standard sample locations + */ } } @@ -790,7 +793,7 @@ vk_dynamic_graphics_state_init_ms(struct vk_dynamic_graphics_state *dst, dst->ms.alpha_to_one_enable = ms->alpha_to_one_enable; dst->ms.sample_locations_enable = ms->sample_locations_enable; - if (IS_NEEDED(MS_SAMPLE_LOCATIONS)) + if (IS_NEEDED(MS_SAMPLE_LOCATIONS) && ms->sample_locations) *dst->ms.sample_locations = *ms->sample_locations; }