Mesa (master): Add mismatch check for glGetTexImage or it will return -1 and may lead to segment fault .

Yuanhan Liu yliu at kemper.freedesktop.org
Wed Dec 14 09:24:05 UTC 2011


Module: Mesa
Branch: master
Commit: 606d3a3c3de94665e47df47b48596293d588a420
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=606d3a3c3de94665e47df47b48596293d588a420

Author: Jian Zhao <jian.j.zhao at intel.com>
Date:   Tue Dec 13 13:31:41 2011 +0800

Add mismatch check for glGetTexImage or it will return -1 and may lead to segment fault.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/texgetimage.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index ae0d51f..3f24187 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -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




More information about the mesa-commit mailing list