summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2014-04-23 09:49:58 -0600
committerBrian Paul <[email protected]>2014-04-24 08:16:01 -0600
commit7cc2e2e99d857617178ce01f52ae2a9b04da3275 (patch)
treeb33c4297ff392224a513df2ad43a0309e49adf2e /src/mesa/swrast
parent15c92464df07c5c0bb23a007358c560faeab76a8 (diff)
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" <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_texture.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index c08a4e9d1e4..1d449a2b44d 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);