[8/10] WineD3D: Check error conditions before creating the object

Stefan Dösinger stefan at codeweavers.com
Tue Feb 13 13:24:39 CST 2007


-------------- next part --------------
From 8516491098b043808137579e1867ca4f521c4f99 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Mon, 29 Jan 2007 22:07:17 +0100
Subject: [PATCH] WineD3D: Check error conditions before creating the object

---
 dlls/wined3d/device.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5804df8..2315a45 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -505,13 +505,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac
     WINED3DFORMAT Format = WINED3DFMT_VERTEXDATA; /* Dummy format for now */
     int dxVersion = ( (IWineD3DImpl *) This->wineD3D)->dxVersion;
     BOOL conv;
+
+    if(Size == 0) {
+        WARN("Size 0 requested, returning WINED3DERR_INVALIDCALL\n");
+        *ppVertexBuffer = NULL;
+        return WINED3DERR_INVALIDCALL;
+    }
+
     D3DCREATERESOURCEOBJECTINSTANCE(object, VertexBuffer, WINED3DRTYPE_VERTEXBUFFER, Size)
 
     TRACE("(%p) : Size=%d, Usage=%d, FVF=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->resource.allocatedMemory, object);
     *ppVertexBuffer = (IWineD3DVertexBuffer *)object;
 
-    if(Size == 0) return WINED3DERR_INVALIDCALL;
-
     if (Pool == WINED3DPOOL_DEFAULT ) { /* Allocate some system memory for now */
         object->resource.allocatedMemory  = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->resource.size);
     }
-- 
1.4.4.3



More information about the wine-patches mailing list