Add mismatch check for glGetTexImage or it will return -1 and may lead to segment...
authorJian Zhao <jian.j.zhao@intel.com>
Tue, 13 Dec 2011 05:31:41 +0000 (13:31 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 14 Dec 2011 09:22:47 +0000 (17:22 +0800)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/texgetimage.c

index ae0d51fbb29aea74e382f87356411f7895218873..3f24187292b5e9a029014579691870f6681b0291 100644 (file)
@@ -708,6 +708,14 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
       return GL_TRUE;
    }
 
+   if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+      /*GL_INVALID_OPERATION is generated by a format/type
+       * mismatch (see the 1.2 spec page 94, sec 3.6.4.)
+       */
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(target)");
+      return GL_TRUE;
+   }
+
    baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
       
    /* Make sure the requested image format is compatible with the