From ee74f6d71079cda75ba94841e4369c519489c879 Mon Sep 17 00:00:00 2001
From: Henri Verbeet <hverbeet@codeweavers.com>
Date: Tue, 11 Nov 2014 22:32:00 +0100
Subject: d3d9: Don't decrease surface refcount when its already zero.

---
 dlls/d3d9/surface.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index e5eb11f..2aab5f3 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -91,6 +91,12 @@ static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
         return IDirect3DBaseTexture9_Release(&surface->texture->IDirect3DBaseTexture9_iface);
     }
 
+    if (!surface->resource.refcount)
+    {
+        ERR("Surface doesn't have any references.\n");
+        return 0;
+    }
+
     refcount = InterlockedDecrement(&surface->resource.refcount);
     TRACE("%p decreasing refcount to %u.\n", iface, refcount);
 
-- 
2.1.3

