gdiplus: Fix memory leak in GdipCreateMetafileFromWMF.
This commit is contained in:
parent
9da6cc907e
commit
cfef981a9a
|
@ -846,11 +846,12 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
|
||||||
GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
|
GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
|
||||||
{
|
{
|
||||||
static int calls;
|
static int calls;
|
||||||
IStream *stream;
|
IStream *stream = NULL;
|
||||||
UINT read;
|
UINT read;
|
||||||
BYTE* copy;
|
BYTE* copy;
|
||||||
METAFILEPICT mfp;
|
METAFILEPICT mfp;
|
||||||
HENHMETAFILE hemf;
|
HENHMETAFILE hemf;
|
||||||
|
GpStatus retval = GenericError;
|
||||||
|
|
||||||
if(!hwmf || !metafile || !placeable)
|
if(!hwmf || !metafile || !placeable)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
@ -882,16 +883,19 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
|
||||||
|
|
||||||
if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){
|
if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){
|
||||||
ERR("could not make stream\n");
|
ERR("could not make stream\n");
|
||||||
return GenericError;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
*metafile = GdipAlloc(sizeof(GpMetafile));
|
*metafile = GdipAlloc(sizeof(GpMetafile));
|
||||||
if(!*metafile) return OutOfMemory;
|
if(!*metafile){
|
||||||
|
retval = OutOfMemory;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
|
if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
|
||||||
(LPVOID*) &((*metafile)->image.picture)) != S_OK){
|
(LPVOID*) &((*metafile)->image.picture)) != S_OK){
|
||||||
GdipFree(*metafile);
|
GdipFree(*metafile);
|
||||||
return GenericError;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*metafile)->image.type = ImageTypeMetafile;
|
(*metafile)->image.type = ImageTypeMetafile;
|
||||||
|
@ -903,11 +907,15 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
|
||||||
- placeable->BoundingBox.Top)) / ((REAL) placeable->Inch);
|
- placeable->BoundingBox.Top)) / ((REAL) placeable->Inch);
|
||||||
(*metafile)->unit = UnitInch;
|
(*metafile)->unit = UnitInch;
|
||||||
|
|
||||||
|
|
||||||
if(delete)
|
if(delete)
|
||||||
DeleteMetaFile(hwmf);
|
DeleteMetaFile(hwmf);
|
||||||
|
|
||||||
return Ok;
|
retval = Ok;
|
||||||
|
|
||||||
|
end:
|
||||||
|
IStream_Release(stream);
|
||||||
|
GdipFree(copy);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
|
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
|
||||||
|
|
Loading…
Reference in New Issue