Commit a1cee57c authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Fix mem leak when GlobalReAlloc() fails.

parent 99bf92e3
...@@ -626,6 +626,7 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize( ...@@ -626,6 +626,7 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */ ULARGE_INTEGER libNewSize) /* [in] */
{ {
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBAL supportHandle;
TRACE("(%p, %ld)\n", iface, libNewSize.s.LowPart); TRACE("(%p, %ld)\n", iface, libNewSize.s.LowPart);
...@@ -641,10 +642,12 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize( ...@@ -641,10 +642,12 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize(
/* /*
* Re allocate the HGlobal to fit the new size of the stream. * Re allocate the HGlobal to fit the new size of the stream.
*/ */
This->supportHandle = GlobalReAlloc(This->supportHandle, supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.s.LowPart, 0);
libNewSize.s.LowPart,
0); if (supportHandle == 0)
return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->streamSize.s.LowPart = libNewSize.s.LowPart; This->streamSize.s.LowPart = libNewSize.s.LowPart;
return S_OK; return S_OK;
......
...@@ -545,6 +545,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize( ...@@ -545,6 +545,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */ ULARGE_INTEGER libNewSize) /* [in] */
{ {
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface; HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
HGLOBAL supportHandle;
/* /*
* As documented. * As documented.
...@@ -558,13 +559,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize( ...@@ -558,13 +559,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
/* /*
* Re allocate the HGlobal to fit the new size of the stream. * Re allocate the HGlobal to fit the new size of the stream.
*/ */
This->supportHandle = GlobalReAlloc(This->supportHandle, supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.s.LowPart, 0);
libNewSize.s.LowPart,
0);
if (This->supportHandle == 0) if (supportHandle == 0)
return STG_E_MEDIUMFULL; return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->byteArraySize.s.LowPart = libNewSize.s.LowPart; This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
return S_OK; return S_OK;
......
...@@ -469,6 +469,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize( ...@@ -469,6 +469,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize(
ULARGE_INTEGER libNewSize) /* [in] */ ULARGE_INTEGER libNewSize) /* [in] */
{ {
HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface; HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
HGLOBAL16 supportHandle;
TRACE("(%p,%ld)\n",This,libNewSize.s.LowPart); TRACE("(%p,%ld)\n",This,libNewSize.s.LowPart);
/* /*
...@@ -483,13 +484,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize( ...@@ -483,13 +484,12 @@ HRESULT WINAPI HGLOBALLockBytesImpl16_SetSize(
/* /*
* Re allocate the HGlobal to fit the new size of the stream. * Re allocate the HGlobal to fit the new size of the stream.
*/ */
This->supportHandle = GlobalReAlloc16(This->supportHandle, supportHandle = GlobalReAlloc16(This->supportHandle, libNewSize.s.LowPart, 0);
libNewSize.s.LowPart,
0);
if (This->supportHandle == 0) if (supportHandle == 0)
return STG_E_MEDIUMFULL; return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->byteArraySize.s.LowPart = libNewSize.s.LowPart; This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
return S_OK; return S_OK;
......
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