From e57233217397d0c660cb9f0b6b857b599fdf6644 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 11 Oct 2014 22:53:26 +0000 Subject: [PATCH] sharkbanana found an edge case. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4766 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index d5566eaaf..9dd737c1f 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -3571,18 +3571,23 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag } - Image_RoundDimensions(&mips->mip[0].width, &mips->mip[0].height, flags); - if (mips->mip[0].width == imgwidth && mips->mip[0].height == imgheight) - mips->mip[0].data = rgbadata; - else + if (rgbadata) { - mips->mip[0].data = BZ_Malloc(((mips->mip[0].width+3)&~3)*mips->mip[0].height*4); -// memset(mips->mip[0].data, 0, mips->mip[0].width*mips->mip[0].height*4); - Image_ResampleTexture(rgbadata, imgwidth, imgheight, mips->mip[0].data, mips->mip[0].width, mips->mip[0].height); - if (freedata) - BZ_Free(rgbadata); - freedata = true; + Image_RoundDimensions(&mips->mip[0].width, &mips->mip[0].height, flags); + if (mips->mip[0].width == imgwidth && mips->mip[0].height == imgheight) + mips->mip[0].data = rgbadata; + else + { + mips->mip[0].data = BZ_Malloc(((mips->mip[0].width+3)&~3)*mips->mip[0].height*4); + // memset(mips->mip[0].data, 0, mips->mip[0].width*mips->mip[0].height*4); + Image_ResampleTexture(rgbadata, imgwidth, imgheight, mips->mip[0].data, mips->mip[0].width, mips->mip[0].height); + if (freedata) + BZ_Free(rgbadata); + freedata = true; + } } + else + mips->mip[0].data = NULL; mips->mip[0].datasize = mips->mip[0].width*mips->mip[0].height*4; if (mips->type == PTI_3D)