[Mesa-dev] [PATCH] mesa: fix glCompressedSubTexture assertion/segfault

Brian Paul brianp at vmware.com
Thu Sep 27 05:51:31 PDT 2012


If the destination texture image doesn't exist we'd hit an assertion
(or crash in a release build).  The piglit/s3tc-errors test hits this.
This has already been fixed in master by the error checking code
consolidation.

Note: This is a candidate for the 8.0 branch.
---
 src/mesa/main/teximage.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e764dd4..4b7fd1c 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3659,6 +3659,11 @@ compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims,
                                    GLsizei depth, GLenum format,
                                    struct gl_texture_image *texImage)
 {
+   if (!texImage) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCompressedTexSubImage%uD(undefined image level)", dims);
+      return GL_TRUE;
+   }
 
    if ((GLint) format != texImage->InternalFormat) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -3770,7 +3775,6 @@ compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
    _mesa_lock_texture(ctx, texObj);
    {
       texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-      assert(texImage);
 
       if (compressed_subtexture_error_check2(ctx, dims, width, height, depth,
                                              format, texImage)) {
-- 
1.7.3.4



More information about the mesa-dev mailing list