From 315e87e1720ddc0129c77afc10c99393b790acc3 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 11 Jul 2017 14:27:01 +0300 Subject: [PATCH] d3dx9: Fix potential memory leak on HeapReAlloc() failure in get_constants_desc(). Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- 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 c51fc6c7d9..deb72e254b 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);