[PATCH] d3drm: added some freeing of memory in error paths (Coverity)

Marcus Meissner marcus at jet.franken.de
Sun Oct 13 04:13:32 CDT 2013


1104553 Resource leak

Ciao, Marcus
---
 dlls/d3drm/frame.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index ea20d15..34e3194 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -757,8 +757,10 @@ static HRESULT WINAPI d3drm_frame2_GetVisuals(IDirect3DRMFrame2 *iface, IDirect3
     {
         ULONG i;
 
-        if (!(array->visuals = HeapAlloc(GetProcessHeap(), 0, frame->nb_visuals * sizeof(*array->visuals))))
+        if (!(array->visuals = HeapAlloc(GetProcessHeap(), 0, frame->nb_visuals * sizeof(*array->visuals)))) {
+            HeapFree(GetProcessHeap(), 0, array);
             return E_OUTOFMEMORY;
+        }
         for (i = 0; i < frame->nb_visuals; ++i)
         {
             array->visuals[i] = frame->visuals[i];
@@ -1505,8 +1507,10 @@ static HRESULT WINAPI d3drm_frame3_GetChildren(IDirect3DRMFrame3 *iface, IDirect
     {
         ULONG i;
 
-        if (!(array->frames = HeapAlloc(GetProcessHeap(), 0, frame->nb_children * sizeof(*array->frames))))
+        if (!(array->frames = HeapAlloc(GetProcessHeap(), 0, frame->nb_children * sizeof(*array->frames)))) {
+            HeapFree(GetProcessHeap(), 0, array);
             return E_OUTOFMEMORY;
+        }
         for (i = 0; i < frame->nb_children; ++i)
         {
             IDirect3DRMFrame3_QueryInterface(frame->children[i], &IID_IDirect3DRMFrame, (void **)&array->frames[i]);
@@ -1543,8 +1547,10 @@ static HRESULT WINAPI d3drm_frame3_GetLights(IDirect3DRMFrame3 *iface, IDirect3D
     {
         ULONG i;
 
-        if (!(array->lights = HeapAlloc(GetProcessHeap(), 0, frame->nb_lights * sizeof(*array->lights))))
+        if (!(array->lights = HeapAlloc(GetProcessHeap(), 0, frame->nb_lights * sizeof(*array->lights)))) {
+            HeapFree(GetProcessHeap(), 0, array);
             return E_OUTOFMEMORY;
+        }
         for (i = 0; i < frame->nb_lights; ++i)
         {
             IDirect3DRMLight_QueryInterface(frame->lights[i], &IID_IDirect3DRMLight, (void **)&array->lights[i]);
-- 
1.7.10.4




More information about the wine-patches mailing list