]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
don't crash on NULL texture upload in dpsoftrast
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 1 Apr 2011 07:23:17 +0000 (07:23 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 1 Apr 2011 21:21:12 +0000 (23:21 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10998 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=33f901a2deb7f1984b7e239ec39b1d1438ef8d08

dpsoftrast.c

index fc703c65cff27593412d35587f4b206806fede4f..c250a2ea8f7b3d0944d00ff69b3337058b6cbc2c 100644 (file)
@@ -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)