Paul Gofman : d3dx9: Fix potential memory leak on HeapReAlloc() failure in get_constants_desc().

Alexandre Julliard julliard at winehq.org
Tue Jul 18 13:58:55 CDT 2017


Module: wine
Branch: master
Commit: 315e87e1720ddc0129c77afc10c99393b790acc3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=315e87e1720ddc0129c77afc10c99393b790acc3

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Tue Jul 11 14:27:01 2017 +0300

d3dx9: Fix potential memory leak on HeapReAlloc() failure in get_constants_desc().

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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);




More information about the wine-cvs mailing list