diff options
author | Brian Paul <[email protected]> | 2010-12-02 14:18:18 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-12-02 14:29:07 -0700 |
commit | 25662f878ea5f3a8c55506d0becafe2c0a6370f2 (patch) | |
tree | 84a970937c3c0cdebfe362f5be87bf0a391d6ba6 /src/mesa/swrast/s_blend.c | |
parent | 2addcb7b50e6f1e821c06a295038194216ca1869 (diff) |
swrast: avoid large stack allocations in blend code
Diffstat (limited to 'src/mesa/swrast/s_blend.c')
-rw-r--r-- | src/mesa/swrast/s_blend.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index 1a550c445d3..d61baba0f33 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -819,7 +819,16 @@ static void blend_general(struct gl_context *ctx, GLuint n, const GLubyte mask[], void *src, const void *dst, GLenum chanType) { - GLfloat rgbaF[MAX_WIDTH][4], destF[MAX_WIDTH][4]; + GLfloat (*rgbaF)[4], (*destF)[4]; + + rgbaF = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + destF = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + if (!rgbaF || !destF) { + free(rgbaF); + free(destF); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "blending"); + return; + } if (chanType == GL_UNSIGNED_BYTE) { GLubyte (*rgba)[4] = (GLubyte (*)[4]) src; @@ -883,6 +892,9 @@ blend_general(struct gl_context *ctx, GLuint n, const GLubyte mask[], blend_general_float(ctx, n, mask, (GLfloat (*)[4]) src, (GLfloat (*)[4]) dst, chanType); } + + free(rgbaF); + free(destF); } |