From: Lawrence S. <ljs...@us...> - 2015-09-09 14:39:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 46ed1d5353edae37064e3154d4ad8e5ee4bae2bc (commit) from 5fce3e1897b6069708bd9f3a9f3d995ccbc1992f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 46ed1d5353edae37064e3154d4ad8e5ee4bae2bc Author: Lawrence Sebald <ljs...@us...> Date: Wed Sep 9 10:39:22 2015 -0400 Don't allocate texture conversion space on the stack, as it is likely to overflow the stack and corrupt heap memory. ----------------------------------------------------------------------- Summary of changes: gl-texture.c | 33 +++++++++++++++------------------ 1 files changed, 15 insertions(+), 18 deletions(-) diff --git a/gl-texture.c b/gl-texture.c index 325843d..fa5a3ef 100755 --- a/gl-texture.c +++ b/gl-texture.c @@ -264,48 +264,45 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, case GL_UNSIGNED_SHORT: case GL_FLOAT: { - uint16 tex[width * height]; - + uint16 *tex; + + tex = (uint16 *)malloc(width * height * sizeof(uint16)); + if(!tex) { + _glKosThrowError(GL_OUT_OF_MEMORY, "glTexImage2D"); + _glKosPrintError(); + return; + } + switch(internalFormat) { case GL_RGB: - _glPixelConvertRGB(type, width, height, (void *)data, tex); - GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED); - sq_cpy(GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data, tex, bytes); - break; case GL_RGBA: - _glPixelConvertRGBA(type, width, height, (void *)data, tex); - GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_ARGB4444 | PVR_TXRFMT_NONTWIDDLED); - sq_cpy(GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data, tex, bytes); - break; } + + free(tex); } break; - + case GL_UNSIGNED_SHORT_5_6_5: /* Texture Formats that do not need conversion */ - case GL_UNSIGNED_SHORT_5_6_5_TWID: - case GL_UNSIGNED_SHORT_1_5_5_5: + case GL_UNSIGNED_SHORT_5_6_5_TWID: + case GL_UNSIGNED_SHORT_1_5_5_5: case GL_UNSIGNED_SHORT_1_5_5_5_TWID: case GL_UNSIGNED_SHORT_4_4_4_4: case GL_UNSIGNED_SHORT_4_4_4_4_TWID: - sq_cpy(GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data, data, bytes); - break; - + default: /* Unsupported Texture Format */ - _glKosThrowError(GL_INVALID_OPERATION, "glTexImage2D"); - break; } } hooks/post-receive -- The KallistiOS port of OpenGL. |