[v2 5/5] d3dx9: Fix potential memory leak on HeapReAlloc() failure in get_constants_desc().

Paul Gofman gofmanp at gmail.com
Tue Jul 11 06:27:01 CDT 2017


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
v2:
    - added patch.
---
 dlls/d3dx9_36/preshader.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index c51fc6c..deb72e2 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -698,15 +698,19 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
     }
     if (out->const_set_count)
     {
-        out->const_set = HeapReAlloc(GetProcessHeap(), 0, out->const_set,
+        struct d3dx_const_param_eval_output *new_alloc;
+
+        new_alloc = HeapReAlloc(GetProcessHeap(), 0, out->const_set,
                 sizeof(*out->const_set) * out->const_set_count);
-        if (!out->const_set)
+        if (new_alloc)
         {
-            ERR("Out of memory.\n");
-            hr = E_OUTOFMEMORY;
-            goto cleanup;
+            out->const_set = new_alloc;
+            out->const_set_size = out->const_set_count;
+        }
+        else
+        {
+            WARN("Out of memory.\n");
         }
-        out->const_set_size = out->const_set_count;
     }
 cleanup:
     ID3DXConstantTable_Release(ctab);
-- 
2.9.4




More information about the wine-patches mailing list