From 08e11a495429c222f150b6d6f8c4936f2f0e0759 Mon Sep 17 00:00:00 2001 From: Ryan Neph Date: Fri, 2 Jul 2021 13:00:56 -0700 Subject: [PATCH] vrend: fix null pointer dereference Caught by fuzzer. surf[0]->texture cannot be assumed to be a valid pointer. Signed-off-by: Ryan Neph Reviewed-by: Yiwei Zhang --- src/vrend_renderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index bd4eb49..aa76a95 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3801,7 +3801,7 @@ void vrend_clear(struct vrend_context *ctx, if (buffers & PIPE_CLEAR_COLOR) { if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_format_is_emulated_alpha(sub_ctx->surf[0]->format)) { glClearColor(color->f[3], 0.0, 0.0, 0.0); - } else if (vrend_resource_is_emulated_bgra(sub_ctx->surf[0]->texture)) { + } else if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_resource_is_emulated_bgra(sub_ctx->surf[0]->texture)) { VREND_DEBUG(dbg_bgra, ctx, "swizzling glClearColor() since rendering surface is an externally-stored BGR* resource\n"); glClearColor(color->f[2], color->f[1], color->f[0], color->f[3]); } else {