mesa: fix glCompressedTexSubImage assertion/segfault
authorBrian Paul <brianp@vmware.com>
Thu, 27 Sep 2012 12:31:25 +0000 (06:31 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 1 Oct 2012 14:24:36 +0000 (08:24 -0600)
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

index e764dd4..4b7fd1c 100644 (file)
@@ -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)) {