mesa: don't crash on incorrect texture use
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 25 Jun 2021 12:33:22 +0000 (22:33 +1000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 29 Jun 2021 01:38:05 +0000 (01:38 +0000)
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4995

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

src/mesa/main/mipmap.c
src/mesa/state_tracker/st_cb_texture.c

index 8f08396..b73413e 100644 (file)
@@ -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;
index a40e0f8..8bf3603 100644 (file)
@@ -2757,7 +2757,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