Mesa (master): mesa: validate size parameters for glTexStorage*Multisample

Tapani Pälli tpalli at kemper.freedesktop.org
Wed Aug 19 04:33:43 UTC 2015


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

Author: Tapani Pälli <tapani.palli at intel.com>
Date:   Mon Aug 17 10:14:35 2015 +0300

mesa: validate size parameters for glTexStorage*Multisample

v2: code cleanup
v3: check only dimensions, samples is checked separately later

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Timothy Arceri <t_arceri at yahoo.com.au>

---

 src/mesa/main/teximage.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 8b2f32a..253e881 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -5794,6 +5794,20 @@ _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
                              "glTexImage3DMultisample");
 }
 
+static bool
+valid_texstorage_ms_parameters(GLsizei width, GLsizei height, GLsizei depth,
+                               GLsizei samples, unsigned dims)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!_mesa_valid_tex_storage_dim(width, height, depth)) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glTexStorage%uDMultisample(width=%d,height=%d,depth=%d)",
+                  dims, width, height, depth);
+      return false;
+   }
+   return true;
+}
 
 void GLAPIENTRY
 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
@@ -5807,6 +5821,9 @@ _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
    if (!texObj)
       return;
 
+   if (!valid_texstorage_ms_parameters(width, height, 1, samples, 2))
+      return;
+
    texture_image_multisample(ctx, 2, texObj, target, samples,
                              internalformat, width, height, 1,
                              fixedsamplelocations, GL_TRUE,
@@ -5826,6 +5843,9 @@ _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
    if (!texObj)
       return;
 
+   if (!valid_texstorage_ms_parameters(width, height, depth, samples, 3))
+      return;
+
    texture_image_multisample(ctx, 3, texObj, target, samples,
                              internalformat, width, height, depth,
                              fixedsamplelocations, GL_TRUE,
@@ -5846,6 +5866,9 @@ _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
    if (!texObj)
       return;
 
+   if (!valid_texstorage_ms_parameters(width, height, 1, samples, 2))
+      return;
+
    texture_image_multisample(ctx, 2, texObj, texObj->Target, samples,
                              internalformat, width, height, 1,
                              fixedsamplelocations, GL_TRUE,
@@ -5867,6 +5890,9 @@ _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
    if (!texObj)
       return;
 
+   if (!valid_texstorage_ms_parameters(width, height, depth, samples, 3))
+      return;
+
    texture_image_multisample(ctx, 3, texObj, texObj->Target, samples,
                              internalformat, width, height, depth,
                              fixedsamplelocations, GL_TRUE,




More information about the mesa-commit mailing list