st/nine: Fix possible segfault in surface ctor
authorAxel Davy <axel.davy@ens.fr>
Wed, 12 Oct 2016 17:10:53 +0000 (19:10 +0200)
committerAxel Davy <axel.davy@ens.fr>
Thu, 13 Oct 2016 19:16:35 +0000 (21:16 +0200)
Regression introduced by
ba0274c7d6c3b77a36bbe1b444f427b0c873e2f3

Check the resource exists before assigning it
a flag (and use This->base.resource instead
of pResource, since the former may have a newly
allocate resource, while the latter would be
NULL).

This should reintroduce the behaviour of previous
code.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/surface9.c

index dc31bb93786e03c16332b8c4e6227a9cf8ce9d8a..664b78f8d5e5e1f00f1a024e0d3d3f0f338f777e 100644 (file)
@@ -187,8 +187,8 @@ NineSurface9_ctor( struct NineSurface9 *This,
 
     This->stride = nine_format_get_stride(This->base.info.format, pDesc->Width);
 
-    if (pDesc->Usage & D3DUSAGE_DYNAMIC)
-        pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
+    if (This->base.resource && (pDesc->Usage & D3DUSAGE_DYNAMIC))
+        This->base.resource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
 
     /* TODO: investigate what else exactly needs to be cleared */
     if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) {