radeon: Don't crash generating mipmaps when pixels=NULL
authorOwen W. Taylor <otaylor@fishsoup.net>
Sat, 9 May 2009 19:23:34 +0000 (15:23 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Wed, 13 May 2009 23:06:24 +0000 (19:06 -0400)
When a NULL value of pixels is passed to TexImage2D and
SGIS_generate_mipmap is enabled, don't try to generate the
mipmap tree: we don't have data yet for the texture and will
crash.

https://bugs.freedesktop.org/show_bug.cgi?id=21648

src/mesa/drivers/dri/radeon/radeon_texture.c

index 0f1d9c2..564da19 100644 (file)
@@ -612,11 +612,10 @@ static void radeon_teximage(
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
                }
 
-       }
-
-       /* SGIS_generate_mipmap */
-       if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-               radeon_generate_mipmap(ctx, texObj->Target, texObj);
+               /* SGIS_generate_mipmap */
+               if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+                       radeon_generate_mipmap(ctx, texObj->Target, texObj);
+               }
        }
 
        _mesa_unmap_teximage_pbo(ctx, packing);
@@ -741,12 +740,12 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, int level,
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
                }
 
+               /* GL_SGIS_generate_mipmap */
+               if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+                       radeon_generate_mipmap(ctx, texObj->Target, texObj);
+               }
        }
 
-       /* GL_SGIS_generate_mipmap */
-       if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-               radeon_generate_mipmap(ctx, texObj->Target, texObj);
-       }
        radeon_teximage_unmap(image);
 
        _mesa_unmap_teximage_pbo(ctx, packing);