ole32: fix mem leak
Dimitrie O. Paun
dpaun at rogers.com
Tue Nov 25 02:05:13 CST 2003
ChangeLog
Fix mem leak when GlobalReAlloc() fails.
Index: ./dlls/ole32/hglobalstream.c
===================================================================
RCS file: /var/cvs/wine/dlls/ole32/hglobalstream.c,v
retrieving revision 1.19
diff -u -r1.19 hglobalstream.c
--- ./dlls/ole32/hglobalstream.c 11 Sep 2003 03:06:25 -0000 1.19
+++ ./dlls/ole32/hglobalstream.c 25 Nov 2003 07:59:56 -0000
@@ -626,6 +626,7 @@
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
+ HGLOBAL supportHandle;
TRACE("(%p, %ld)\n", iface, libNewSize.s.LowPart);
@@ -641,10 +642,12 @@
/*
* 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;
Index: ./dlls/ole32/memlockbytes.c
===================================================================
RCS file: /var/cvs/wine/dlls/ole32/memlockbytes.c,v
retrieving revision 1.15
diff -u -r1.15 memlockbytes.c
--- ./dlls/ole32/memlockbytes.c 11 Sep 2003 03:06:25 -0000 1.15
+++ ./dlls/ole32/memlockbytes.c 25 Nov 2003 07:59:04 -0000
@@ -545,6 +545,7 @@
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
+ HGLOBAL supportHandle;
/*
* As documented.
@@ -558,13 +559,12 @@
/*
* 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;
Index: ./dlls/ole32/memlockbytes16.c
===================================================================
RCS file: /var/cvs/wine/dlls/ole32/memlockbytes16.c,v
retrieving revision 1.4
diff -u -r1.4 memlockbytes16.c
--- ./dlls/ole32/memlockbytes16.c 9 Sep 2003 19:39:31 -0000 1.4
+++ ./dlls/ole32/memlockbytes16.c 25 Nov 2003 08:01:31 -0000
@@ -469,6 +469,7 @@
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
+ HGLOBAL16 supportHandle;
TRACE("(%p,%ld)\n",This,libNewSize.s.LowPart);
/*
@@ -483,13 +484,12 @@
/*
* 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;
--
Dimi.
More information about the wine-patches
mailing list