From eb597d2ce14926e379427c485c76dffc7641454d Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 25 Jun 2021 22:33:22 +1000 Subject: [PATCH] mesa: don't crash on incorrect texture use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4995 Reviewed-by: Marek Olšák Reviewed-by: Ian Romanick Part-of: (cherry picked from commit 328ea8e04accfa4e156c37959714f5bc92cb0421) --- .pick_status.json | 2 +- src/mesa/main/mipmap.c | 4 ++++ src/mesa/state_tracker/st_cb_texture.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7047276876a..e818c54e27b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -508,7 +508,7 @@ "description": "mesa: don't crash on incorrect texture use", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 8f08396fe15..b73413ee51f 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1913,6 +1913,10 @@ _mesa_prepare_mipmap_levels(struct gl_context *ctx, { const struct gl_texture_image *baseImage = _mesa_select_tex_image(texObj, texObj->Target, baseLevel); + + if (baseImage == NULL) + return; + const GLint border = 0; GLint width = baseImage->Width; GLint height = baseImage->Height; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 6b269196167..64b9009552d 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -2751,7 +2751,8 @@ st_finalize_texture(struct gl_context *ctx, firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace] [stObj->base.Attrib.BaseLevel]); - assert(firstImage); + if (!firstImage) + return false; /* If both firstImage and stObj point to a texture which can contain * all active images, favour firstImage. Note that because of the