st/nine: Fix GenerateMipSubLevels potential crash
authorPatrick Rudolph <siro@das-labor.org>
Tue, 12 May 2015 18:07:09 +0000 (20:07 +0200)
committerAxel Davy <axel.davy@ens.fr>
Fri, 21 Aug 2015 20:21:46 +0000 (22:21 +0200)
For the case of D3DPOOL_MANAGED textures, This->base.resource can be NULL
at the start of the function. In This case, UploadSelf will take care
of the defining. Assign resource after the UploadSelf call
to prevent NULL pointer exception.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
src/gallium/state_trackers/nine/basetexture9.c

index 110df79769e75501fea1dabc449477b3d4065a72..48fccb242bb587e1d394483234ee495efad23720 100644 (file)
@@ -385,8 +385,7 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This )
 void WINAPI
 NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
 {
-    struct pipe_resource *resource = This->base.resource;
-
+    struct pipe_resource *resource;
     unsigned base_level = 0;
     unsigned last_level = This->base.info.last_level - This->managed.lod;
     unsigned first_layer = 0;
@@ -409,6 +408,8 @@ NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
 
     last_layer = util_max_layer(This->view[0]->texture, base_level);
 
+    resource = This->base.resource;
+
     util_gen_mipmap(This->pipe, resource,
                     resource->format, base_level, last_level,
                     first_layer, last_layer, filter);