From 4cc3554d85b1852debea21ee87c31bb7ffb8e203 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 26 Aug 2021 00:09:44 +0200 Subject: [PATCH] zink: do not dereference null-pointer The "locations" pointer can be null here, and memcpying from a null pointer is not okay. CID: 1485978 Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 9f33d35..7e21778 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2059,7 +2059,9 @@ zink_set_sample_locations(struct pipe_context *pctx, size_t size, const uint8_t ctx->sample_locations_changed = ctx->gfx_pipeline_state.sample_locations_enabled; if (size > sizeof(ctx->sample_locations)) size = sizeof(ctx->sample_locations); - memcpy(ctx->sample_locations, locations, size); + + if (locations) + memcpy(ctx->sample_locations, locations, size); } static VkAccessFlags -- 2.7.4