Vincent Povirk : windowscodecs: Fix memory leak in ComponentFactory_CreateBitmapFromSource.

Alexandre Julliard julliard at winehq.org
Wed Jun 18 14:31:41 CDT 2014


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri Jun  6 15:28:09 2014 -0500

windowscodecs: Fix memory leak in ComponentFactory_CreateBitmapFromSource.

---

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




More information about the wine-cvs mailing list