[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH V4 2/2] d3dx9_36: Add more checks for D3DXOptimizeFaces
From:       Vijay Kiran Kamuju <infyquest () gmail ! com>
Date:       2020-04-30 14:48:43
Message-ID: CACfa+KJPaMTyfTZU66EhLPRTn=O_iB8sxfbKuWJ7tWnv-rtDZw () mail ! gmail ! com
[Download RAW message or body]

Remove warnings

Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>

["0002-d3dx9_36-Add-more-checks-for-D3DXOptimizeFaces.patch" (text/x-patch)]

From b8869e2541dd90213a847b28d97522fccd1bb734 Mon Sep 17 00:00:00 2001
From: Vijay Kiran Kamuju <infyquest@gmail.com>
Date: Fri, 17 Apr 2020 14:57:40 +0200
Subject: [PATCH V4 2/2] d3dx9_36: Add more checks for D3DXOptimizeFaces

Remove warnings

Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>
---
 dlls/d3dx9_36/mesh.c       | 15 ++++++---------
 dlls/d3dx9_36/tests/mesh.c | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index 35eb933223..f277a5d8f4 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -7239,8 +7239,7 @@ error:
 HRESULT WINAPI D3DXOptimizeFaces(const void *indices, UINT num_faces,
         UINT num_vertices, BOOL indices_are_32bit, DWORD *face_remap)
 {
-    UINT i;
-    UINT j = num_faces - 1;
+    UINT i, j;
     UINT limit_16_bit = 2 << 15; /* According to MSDN */
     HRESULT hr = D3D_OK;
 
@@ -7248,17 +7247,16 @@ HRESULT WINAPI D3DXOptimizeFaces(const void *indices, UINT num_faces,
             "Face order will not be optimal.\n",
             indices, num_faces, num_vertices, indices_are_32bit, face_remap);
 
-    if (!indices_are_32bit && num_faces >= limit_16_bit)
+    if (!indices || !num_faces || !num_vertices || !face_remap)
     {
-        WARN("Number of faces must be less than %d when using 16-bit indices.\n",
-             limit_16_bit);
         hr = D3DERR_INVALIDCALL;
         goto error;
     }
 
-    if (!face_remap)
+    if (!indices_are_32bit && num_faces >= limit_16_bit)
     {
-        WARN("Face remap pointer is NULL.\n");
+        WARN("Number of faces must be less than %d when using 16-bit indices.\n",
+             limit_16_bit);
         hr = D3DERR_INVALIDCALL;
         goto error;
     }
@@ -7270,13 +7268,12 @@ HRESULT WINAPI D3DXOptimizeFaces(const void *indices, UINT num_faces,
      *
      * TODO Re-order to take advantage of vertex cache.
      */
+    j = num_faces - 1;
     for (i = 0; i < num_faces; i++)
     {
         face_remap[i] = j--;
     }
 
-    return D3D_OK;
-
 error:
     return hr;
 }
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index 2e5e76a885..3135caa00e 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -10513,6 +10513,27 @@ static void test_optimize_faces(void)
         HeapFree(GetProcessHeap(), 0, face_remap);
     }
 
+    /* indices must not be NULL */
+    hr = D3DXOptimizeFaces(NULL, tc[0].num_faces,
+                           tc[0].num_vertices, tc[0].indices_are_32bit,
+                           NULL);
+    ok(hr == D3DERR_INVALIDCALL, "D3DXOptimizeFaces passed NULL indices "
+       "pointer. Got %x\n, expected D3DERR_INVALIDCALL\n", hr);
+
+    /* num_faces must not be 0 */
+    hr = D3DXOptimizeFaces(tc[0].indices, 0,
+                           tc[0].num_vertices, tc[0].indices_are_32bit,
+                           NULL);
+    ok(hr == D3DERR_INVALIDCALL, "D3DXOptimizeFaces passed 0 num_faces. "
+       "Got %x\n, expected D3DERR_INVALIDCALL\n", hr);
+
+    /* num_vertices must not be 0 */
+    hr = D3DXOptimizeFaces(tc[0].indices, tc[0].num_faces,
+                           0, tc[0].indices_are_32bit,
+                           NULL);
+    ok(hr == D3DERR_INVALIDCALL, "D3DXOptimizeFaces passed 0 num_vertices. "
+       "Got %x\n, expected D3DERR_INVALIDCALL\n", hr);
+
     /* face_remap must not be NULL */
     hr = D3DXOptimizeFaces(tc[0].indices, tc[0].num_faces,
                            tc[0].num_vertices, tc[0].indices_are_32bit,
-- 
2.26.2



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic