Mesa (main): zink: do not dereference null-pointer

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 18:42:40 UTC 2021


Module: Mesa
Branch: main
Commit: 4cc3554d85b1852debea21ee87c31bb7ffb8e203
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cc3554d85b1852debea21ee87c31bb7ffb8e203

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Thu Aug 26 00:09:44 2021 +0200

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 <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12559>

---

 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 9f33d35a699..7e217781862 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



More information about the mesa-commit mailing list