Mesa (master): swrast: allocate swrast_texture_image:: ImageSlices array if needed

Brian Paul brianp at kemper.freedesktop.org
Thu Apr 24 14:34:30 UTC 2014


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Apr 23 09:49:58 2014 -0600

swrast: allocate swrast_texture_image::ImageSlices array if needed

Fixes a segmentation fault in conform divzero.c test.
This happens when glTexImage(level, width=0, height=0) is called.  We
don't allocate texture memory in that case so the ImageSlices array
was never allocated.

Cc: "10.1" <mesa-stable at lists.freedesktop.org>

Reviewed-by: José Fonseca <jfonseca at vmware.com>

---

 src/mesa/swrast/s_texture.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index c08a4e9..1d449a2 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -279,6 +279,13 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
             continue;
          }
 
+         if (!swImage->ImageSlices) {
+            swImage->ImageSlices =
+               calloc(texture_slices(texImage), sizeof(void *));
+            if (!swImage->ImageSlices)
+               continue;
+         }
+
          for (i = 0; i < texture_slices(texImage); i++) {
             GLubyte *map;
             GLint rowStride;
@@ -325,6 +332,9 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
          if (swImage->Buffer)
             return;
 
+         if (!swImage->ImageSlices)
+            continue;
+
          for (i = 0; i < texture_slices(texImage); i++) {
             if (swImage->ImageSlices[i]) {
                ctx->Driver.UnmapTextureImage(ctx, texImage, i);




More information about the mesa-commit mailing list