windowscodecs: Fix memory leak in ComponentFactory_CreateBitmapFromSource.

Vincent Povirk madewokherd at gmail.com
Tue Jun 17 16:04:32 CDT 2014


-------------- next part --------------
From 9dfb044b020597e97e7781119b09031a2080f3f9 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Fri, 6 Jun 2014 15:28:09 -0500
Subject: [PATCH] windowscodecs: Fix memory leak in
 ComponentFactory_CreateBitmapFromSource.

For bug 36593.
---
 dlls/windowscodecs/imgfactory.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index b969313..e7095dd 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -547,20 +547,22 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
             IWICBitmapLock_Release(lock);
         }
 
-        if (SUCCEEDED(hr))
-            hr = PaletteImpl_Create(&palette);
-
         if (SUCCEEDED(hr) && (format_type == WICPixelFormatNumericRepresentationUnspecified ||
                               format_type == WICPixelFormatNumericRepresentationIndexed))
         {
-            hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
+            hr = PaletteImpl_Create(&palette);
 
             if (SUCCEEDED(hr))
-                hr = IWICBitmap_SetPalette(result, palette);
-            else
-                hr = S_OK;
+            {
+                hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
+
+                if (SUCCEEDED(hr))
+                    hr = IWICBitmap_SetPalette(result, palette);
+                else
+                    hr = S_OK;
 
-            IWICPalette_Release(palette);
+                IWICPalette_Release(palette);
+            }
         }
 
         if (SUCCEEDED(hr))
-- 
1.8.3.2



More information about the wine-patches mailing list