From: havoc Date: Fri, 1 Apr 2011 07:23:17 +0000 (+0000) Subject: don't crash on NULL texture upload in dpsoftrast X-Git-Tag: xonotic-v0.6.0~163^2~548 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=33f901a2deb7f1984b7e239ec39b1d1438ef8d08;p=xonotic%2Fdarkplaces.git don't crash on NULL texture upload in dpsoftrast git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10998 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/dpsoftrast.c b/dpsoftrast.c index fc703c65..c250a2ea 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -692,13 +692,16 @@ void DPSOFTRAST_Texture_UpdatePartial(int index, int mip, const unsigned char *p texture = DPSOFTRAST_Texture_GetByIndex(index);if (!texture) return; if (texture->binds) DPSOFTRAST_Flush(); - dst = texture->bytes + (blocky * texture->mipmap[0][2] + blockx) * 4; - while (blockheight > 0) + if (pixels) { - memcpy(dst, pixels, blockwidth * 4); - pixels += blockwidth * 4; - dst += texture->mipmap[0][2] * 4; - blockheight--; + dst = texture->bytes + (blocky * texture->mipmap[0][2] + blockx) * 4; + while (blockheight > 0) + { + memcpy(dst, pixels, blockwidth * 4); + pixels += blockwidth * 4; + dst += texture->mipmap[0][2] * 4; + blockheight--; + } } DPSOFTRAST_Texture_CalculateMipmaps(index); } @@ -708,7 +711,8 @@ void DPSOFTRAST_Texture_UpdateFull(int index, const unsigned char *pixels) texture = DPSOFTRAST_Texture_GetByIndex(index);if (!texture) return; if (texture->binds) DPSOFTRAST_Flush(); - memcpy(texture->bytes, pixels, texture->mipmap[0][1]); + if (pixels) + memcpy(texture->bytes, pixels, texture->mipmap[0][1]); DPSOFTRAST_Texture_CalculateMipmaps(index); } int DPSOFTRAST_Texture_GetWidth(int index, int mip)