Mesa (master): mesa/getteximage: Add validation of target to glGetTextureImage

Eduardo Lima Mitev elima at kemper.freedesktop.org
Thu Nov 24 07:25:35 UTC 2016


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

Author: Eduardo Lima Mitev <elima at igalia.com>
Date:   Wed Nov 23 14:09:59 2016 +0100

mesa/getteximage: Add validation of target to glGetTextureImage

There is an specific list of texture targets that can be used with
glGetTextureImage. From OpenGL 4.5 spec, section '8.11 Texture Queries',
page 234 of the PDF:

   "An INVALID_ENUM error is generated if the effective target is
    not one of TEXTURE_1D , TEXTURE_2D , TEXTURE_3D , TEXTURE_1D_-
    ARRAY , TEXTURE_2D_ARRAY , TEXTURE_CUBE_MAP_ARRAY , TEXTURE_-
    RECTANGLE , one of the targets from table 8.19 (for GetTexImage
    and GetnTexImage only), or TEXTURE_CUBE_MAP (for GetTextureImage
    only)."

We are currently not validating the target for glGetTextureImage. As
an example, calling this function on a texture with target
GL_TEXTURE_2D_MULTISAMPLE should return INVALID_ENUM, but instead it
hits an assertion down the road in the i965 driver.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/mesa/main/texgetimage.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 0186819..d5cb163 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -1429,6 +1429,11 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type,
       return;
    }
 
+   if (!legal_getteximage_target(ctx, texObj->Target, true)) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
+      return;
+   }
+
    get_texture_image_dims(texObj, texObj->Target, level,
                           &width, &height, &depth);
 




More information about the mesa-commit mailing list