Mesa (staging/21.1): mesa: don't crash on incorrect texture use

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 30 08:10:54 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: f2a52742ee94dd5c84773101ee1814304d2c8012
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2a52742ee94dd5c84773101ee1814304d2c8012

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Jun 25 22:33:22 2021 +1000

mesa: don't crash on incorrect texture use

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4995

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11603>
(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



More information about the mesa-commit mailing list