Evan Stade : gdiplus: Don't prematurely release stream.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Aug 8 08:59:47 CDT 2007


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

Author: Evan Stade <estade at gmail.com>
Date:   Tue Aug  7 18:42:16 2007 -0700

gdiplus: Don't prematurely release stream.

---

 dlls/gdiplus/graphics.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 8d31661..3afdab2 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -803,6 +803,8 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
 
     if(!hwmf || !metafile || !placeable)
         return InvalidParameter;
+
+    *metafile = NULL;
     read = GetMetaFileBitsEx(hwmf, 0, NULL);
     if(!read)
         return GenericError;
@@ -819,20 +821,20 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
 
     if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){
         ERR("could not make stream\n");
-        goto end;
+        GdipFree(copy);
+        goto err;
     }
 
     *metafile = GdipAlloc(sizeof(GpMetafile));
     if(!*metafile){
         retval = OutOfMemory;
-        goto end;
+        goto err;
     }
 
     if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
-        (LPVOID*) &((*metafile)->image.picture)) != S_OK){
-        GdipFree(*metafile);
-        goto end;
-    }
+        (LPVOID*) &((*metafile)->image.picture)) != S_OK)
+        goto err;
+
 
     (*metafile)->image.type = ImageTypeMetafile;
     (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
@@ -846,11 +848,11 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
     if(delete)
         DeleteMetaFile(hwmf);
 
-    retval = Ok;
+    return Ok;
 
-end:
+err:
+    GdipFree(*metafile);
     IStream_Release(stream);
-    GdipFree(copy);
     return retval;
 }
 




More information about the wine-cvs mailing list