Commit 34a0463b authored by Joris Huizer's avatar Joris Huizer Committed by Alexandre Julliard

A few memory checks avoiding memory leaks.

parent ba5eb147
...@@ -938,12 +938,15 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF ...@@ -938,12 +938,15 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF
std.tymed = pFormatetc->tymed = TYMED_ISTORAGE; std.tymed = pFormatetc->tymed = TYMED_ISTORAGE;
hStorage = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, 0); hStorage = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, 0);
if (hStorage == NULL)
HANDLE_ERROR( E_OUTOFMEMORY );
hr = CreateILockBytesOnHGlobal(hStorage, FALSE, &ptrILockBytes); hr = CreateILockBytesOnHGlobal(hStorage, FALSE, &ptrILockBytes);
hr = StgCreateDocfileOnILockBytes(ptrILockBytes, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &std.u.pstg); hr = StgCreateDocfileOnILockBytes(ptrILockBytes, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &std.u.pstg);
if (FAILED(hr = IDataObject_GetDataHere(theOleClipboard->pIDataObjectSrc, pFormatetc, &std))) if (FAILED(hr = IDataObject_GetDataHere(theOleClipboard->pIDataObjectSrc, pFormatetc, &std)))
{ {
WARN("() : IDataObject_GetDataHere failed to render clipboard data! (%lx)\n", hr); WARN("() : IDataObject_GetDataHere failed to render clipboard data! (%lx)\n", hr);
GlobalFree(hStorage);
return hr; return hr;
} }
...@@ -1023,10 +1026,11 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF ...@@ -1023,10 +1026,11 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF
else else
{ {
if (FAILED(hr = IDataObject_GetData(pIDataObject, pFormatetc, &std))) if (FAILED(hr = IDataObject_GetData(pIDataObject, pFormatetc, &std)))
{ {
WARN("() : IDataObject_GetData failed to render clipboard data! (%lx)\n", hr); WARN("() : IDataObject_GetData failed to render clipboard data! (%lx)\n", hr);
return hr; GlobalFree(hStorage);
} return hr;
}
/* To put a copy back on the clipboard */ /* To put a copy back on the clipboard */
...@@ -1079,7 +1083,10 @@ static HGLOBAL OLEClipbrd_GlobalDupMem( HGLOBAL hGlobalSrc ) ...@@ -1079,7 +1083,10 @@ static HGLOBAL OLEClipbrd_GlobalDupMem( HGLOBAL hGlobalSrc )
pGlobalSrc = GlobalLock(hGlobalSrc); pGlobalSrc = GlobalLock(hGlobalSrc);
pGlobalDest = GlobalLock(hGlobalDest); pGlobalDest = GlobalLock(hGlobalDest);
if ( !pGlobalSrc || !pGlobalDest ) if ( !pGlobalSrc || !pGlobalDest )
{
GlobalFree(hGlobalDest);
return 0; return 0;
}
memcpy(pGlobalDest, pGlobalSrc, cBytes); memcpy(pGlobalDest, pGlobalSrc, cBytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment