From 33f901a2deb7f1984b7e239ec39b1d1438ef8d08 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 1 Apr 2011 07:23:17 +0000 Subject: [PATCH] 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 --- dpsoftrast.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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) -- 2.39.2