Fix mem leak when GlobalReAlloc() fails.

This commit is contained in:
Dimitrie O. Paun 2003-11-26 03:36:18 +00:00 committed by Alexandre Julliard
parent 99bf92e338
commit a1cee57ce9
3 changed files with 14 additions and 11 deletions

View File

@ -626,6 +626,7 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBAL supportHandle;
TRACE("(%p, %ld)\n", iface, libNewSize.s.LowPart);
@ -641,10 +642,12 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize(
/*
* Re allocate the HGlobal to fit the new size of the stream.
*/
This->supportHandle = GlobalReAlloc(This->supportHandle,
libNewSize.s.LowPart,
0);
supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.s.LowPart, 0);
if (supportHandle == 0)
return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->streamSize.s.LowPart = libNewSize.s.LowPart;
return S_OK;

View File

@ -545,6 +545,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
HGLOBAL supportHandle;
/*
* As documented.
@ -558,13 +559,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
/*
* Re allocate the HGlobal to fit the new size of the stream.
*/
This->supportHandle = GlobalReAlloc(This->supportHandle,
libNewSize.s.LowPart,
0);
supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.s.LowPart, 0);
if (This->supportHandle == 0)
if (supportHandle == 0)
return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
return S_OK;

View File

@ -469,6 +469,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
HGLOBAL16 supportHandle;
TRACE("(%p,%ld)\n",This,libNewSize.s.LowPart);
/*
@ -483,13 +484,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize(
/*
* Re allocate the HGlobal to fit the new size of the stream.
*/
This->supportHandle = GlobalReAlloc16(This->supportHandle,
libNewSize.s.LowPart,
0);
supportHandle = GlobalReAlloc16(This->supportHandle, libNewSize.s.LowPart, 0);
if (This->supportHandle == 0)
if (supportHandle == 0)
return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
return S_OK;