Mesa (main): zink: avoid memcmping null pointers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 18:42:41 UTC 2021
Module: Mesa
Branch: main
Commit: 75b5f12407ec606ae8e83acbc170585ad6e360c1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=75b5f12407ec606ae8e83acbc170585ad6e360c1
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Thu Aug 26 11:36:21 2021 +0200
zink: avoid memcmping null pointers
memcmping NULL pointers is not allowed, and would lead to a crash here.
So let's check that the first isn't NULL; we've already checked that
they're not *both* NULL, so checking one is enough.
CID: 1484801, 1484810
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_program.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c
index 8fe0268baae..8de9d30a524 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -336,7 +336,9 @@ equals_gfx_pipeline_state(const void *a, const void *b)
if (sa->dyn_state1.front_face != sb->dyn_state1.front_face)
return false;
if (!!sa->dyn_state1.depth_stencil_alpha_state != !!sb->dyn_state1.depth_stencil_alpha_state ||
- memcmp(sa->dyn_state1.depth_stencil_alpha_state, sb->dyn_state1.depth_stencil_alpha_state, sizeof(struct zink_depth_stencil_alpha_hw_state)))
+ (sa->dyn_state1.depth_stencil_alpha_state &&
+ memcmp(sa->dyn_state1.depth_stencil_alpha_state, sb->dyn_state1.depth_stencil_alpha_state,
+ sizeof(struct zink_depth_stencil_alpha_hw_state))))
return false;
}
if (!sa->have_EXT_extended_dynamic_state2) {
More information about the mesa-commit
mailing list