summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_zoom.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-12-05 20:40:48 -0700
committerBrian Paul <[email protected]>2011-12-08 08:56:31 -0700
commit24e648490921a386fc3f65d1b1ed330067a4bb25 (patch)
treeb354190a83ec1dc91862639b8d178d5004b5707d /src/mesa/swrast/s_zoom.c
parentbf6aac24c1d77979280068787b5443dd5c049269 (diff)
swrast: use malloc instead of MAX_WIDTH arrays in glCopyPixels, zoom code
Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/swrast/s_zoom.c')
-rw-r--r--src/mesa/swrast/s_zoom.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c
index 16bb997f36c..f407fdcf4e6 100644
--- a/src/mesa/swrast/s_zoom.c
+++ b/src/mesa/swrast/s_zoom.c
@@ -299,11 +299,17 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span,
* Also, clipping may change the span end value, so store it as well.
*/
const GLint end = zoomed.end; /* save */
- GLuint rgbaSave[MAX_WIDTH][4];
+ void *rgbaSave;
const GLint pixelSize =
(zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) :
((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort)
: 4 * sizeof(GLfloat));
+
+ rgbaSave = malloc(zoomed.end * pixelSize);
+ if (!rgbaSave) {
+ return;
+ }
+
if (y1 - y0 > 1) {
memcpy(rgbaSave, zoomed.array->rgba, zoomed.end * pixelSize);
}
@@ -315,6 +321,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span,
memcpy(zoomed.array->rgba, rgbaSave, zoomed.end * pixelSize);
}
}
+
+ free(rgbaSave);
}
}