st/nine: handle possible failure of D3DWindowBuffer_create
authorPatrick Rudolph <siro@das-labor.org>
Sat, 24 Sep 2016 09:34:33 +0000 (11:34 +0200)
committerAxel Davy <axel.davy@ens.fr>
Mon, 10 Oct 2016 21:43:51 +0000 (23:43 +0200)
Check for errors and pass them to the callers.

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

index e611118..03bdcd3 100644 (file)
@@ -542,6 +542,10 @@ create_present_buffer( struct NineSwapChain9 *This,
     *resource = This->screen->resource_create(This->screen, &tmplt);
 
     *present_handle = D3DWindowBuffer_create(This, *resource, 24, true);
+
+    if (!*present_handle) {
+        pipe_resource_reference(resource, NULL);
+    }
 }
 
 static void
@@ -878,6 +882,10 @@ NineSwapChain9_GetFrontBufferData( struct NineSwapChain9 *This,
      * mode. It may need a fix */
     create_present_buffer(This, width, height, &temp_resource, &temp_handle);
 
+    if (!temp_resource || !temp_handle) {
+        return D3DERR_INVALIDCALL;
+    }
+
     desc.Type = D3DRTYPE_SURFACE;
     desc.Pool = D3DPOOL_DEFAULT;
     desc.MultiSampleType = D3DMULTISAMPLE_NONE;