diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index 99077026efc..286739b165f 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -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; diff --git a/dlls/ole32/memlockbytes.c b/dlls/ole32/memlockbytes.c index 4c9a6d6f012..ce5bd0398f2 100644 --- a/dlls/ole32/memlockbytes.c +++ b/dlls/ole32/memlockbytes.c @@ -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; diff --git a/dlls/ole32/memlockbytes16.c b/dlls/ole32/memlockbytes16.c index c48fb63dcf2..5c0f908ca1a 100644 --- a/dlls/ole32/memlockbytes16.c +++ b/dlls/ole32/memlockbytes16.c @@ -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;