diff --git a/src/client/refresh/gl1/gl1_image.c b/src/client/refresh/gl1/gl1_image.c index 284b93a5..5573a955 100644 --- a/src/client/refresh/gl1/gl1_image.c +++ b/src/client/refresh/gl1/gl1_image.c @@ -785,16 +785,8 @@ R_Upload32(unsigned *data, int width, int height, qboolean mipmap) qboolean R_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) { - unsigned trans[1024 * 1024]; - int i, s; - int p; - - s = width * height; - - if (s > sizeof(trans) / 4) - { - ri.Sys_Error(ERR_DROP, "%s: too large", __func__); - } + int s = width * height; + unsigned *trans = malloc(s * sizeof(unsigned)); if (gl_config.palettedtexture && is_sky) { @@ -809,9 +801,9 @@ R_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) } else { - for (i = 0; i < s; i++) + for (int i = 0; i < s; i++) { - p = data[i]; + int p = data[i]; trans[i] = d_8to24table[p]; /* transparent, so scan around for @@ -846,7 +838,9 @@ R_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) } } - return R_Upload32(trans, width, height, mipmap); + qboolean ret = R_Upload32(trans, width, height, mipmap); + free(trans); + return ret; } } diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c index 0126e768..db7209fb 100644 --- a/src/client/refresh/gl3/gl3_image.c +++ b/src/client/refresh/gl3/gl3_image.c @@ -238,20 +238,12 @@ GL3_Upload32(unsigned *data, int width, int height, qboolean mipmap) qboolean GL3_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) { - unsigned trans[1024 * 1024]; - int i, s; - int p; + int s = width * height; + unsigned *trans = malloc(s * sizeof(unsigned)); - s = width * height; - - if (s > sizeof(trans) / 4) + for (int i = 0; i < s; i++) { - ri.Sys_Error(ERR_DROP, "%s: too large", __func__); - } - - for (i = 0; i < s; i++) - { - p = data[i]; + int p = data[i]; trans[i] = d_8to24table[p]; /* transparent, so scan around for @@ -286,7 +278,9 @@ GL3_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) } } - return GL3_Upload32(trans, width, height, mipmap); + qboolean ret = GL3_Upload32(trans, width, height, mipmap); + free(trans); + return ret; } typedef struct