[dlls/user] Memleak fixes.
Peter Berg Larsen
pebl at math.ku.dk
Fri Mar 11 04:48:09 CST 2005
Changelog:
Assorted memleak fixes in dlls/user/*.
Found on Michael Stefaniuc smatch list.
The first hunk is not actually a leak as there us a test above ensuring
that the dwflag is consistens.
Index: dlls/user/lstr.c
===================================================================
RCS file: /home/wine/wine/dlls/user/lstr.c,v
retrieving revision 1.32
diff -u -r1.32 lstr.c
--- dlls/user/lstr.c 28 Jan 2005 11:29:37 -0000 1.32
+++ dlls/user/lstr.c 10 Mar 2005 22:56:22 -0000
@@ -624,11 +624,11 @@
char *source = MapSL(lpSource);
from = HeapAlloc( GetProcessHeap(), 0, strlen(source)+1 );
strcpy( from, source );
- }
+ } else
if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) {
from = HeapAlloc( GetProcessHeap(),0,200 );
sprintf(from,"Systemmessage, messageid = 0x%08x\n",dwMessageId);
- }
+ } else
if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) {
INT16 bufsize;
HINSTANCE16 hinst16 = ((HINSTANCE16)lpSource & 0xffff);
Index: dlls/user/message.c
===================================================================
RCS file: /home/wine/wine/dlls/user/message.c,v
retrieving revision 1.66
diff -u -r1.66 message.c
--- dlls/user/message.c 8 Mar 2005 17:00:38 -0000 1.66
+++ dlls/user/message.c 10 Mar 2005 22:56:34 -0000
@@ -1413,12 +1413,18 @@
if (size)
{
hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, size );
- if (hMem && (ptr = GlobalLock( hMem )))
+ if (hMem == NULL) return FALSE;
+
+ if (ptr = GlobalLock( hMem ))
{
memcpy( ptr, *buffer, size );
GlobalUnlock( hMem );
}
- else return FALSE;
+ else
+ {
+ GlobalFree( hMem );
+ return FALSE;
+ }
}
uiLo = (UINT)hMem;
@@ -1429,7 +1435,9 @@
{
if (!buffer || !*buffer) return FALSE;
hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, size );
- if (hMem && (ptr = GlobalLock( hMem )))
+ if (hMem == NULL) return FALSE;
+
+ if (ptr = GlobalLock( hMem ))
{
memcpy( ptr, *buffer, size );
GlobalUnlock( hMem );
@@ -1439,7 +1447,12 @@
GlobalFree( hMem );
return FALSE;
}
- }
+ }
+ else
+ {
+ GlobalFree( hMem );
+ return FALSE;
+ }
} else return FALSE;
*lparam = (LPARAM)hMem;
break;
More information about the wine-patches
mailing list