Assorted memleak fixes. Found on Michael Stefaniuc smatch list.

This commit is contained in:
Peter Berg Larsen 2005-03-14 10:03:39 +00:00 committed by Alexandre Julliard
parent 2444f4af09
commit 4293b614c4
2 changed files with 25 additions and 15 deletions

View File

@ -1262,13 +1262,17 @@ HANDLE X11DRV_CLIPBOARD_ImportClipboardData(LPBYTE lpdata, UINT cBytes)
{
/* Turn on the DDESHARE flag to enable shared 32 bit memory */
hClipData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, cBytes);
if (hClipData == 0) return NULL;
if ((lpClipData = GlobalLock(hClipData)))
{
memcpy(lpClipData, lpdata, cBytes);
GlobalUnlock(hClipData);
}
else
else {
GlobalFree(hClipData);
hClipData = 0;
}
}
return hClipData;
@ -1296,6 +1300,7 @@ HANDLE X11DRV_CLIPBOARD_ExportClipboardData(Window requestor, Atom aTarget,
cBytes = GlobalSize(lpData->hData32);
hClipData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, cBytes);
if (hClipData == 0) return NULL;
if ((lpClipData = GlobalLock(hClipData)))
{
@ -1306,6 +1311,9 @@ HANDLE X11DRV_CLIPBOARD_ExportClipboardData(Window requestor, Atom aTarget,
GlobalUnlock(lpData->hData32);
GlobalUnlock(hClipData);
} else {
GlobalFree(hClipData);
hClipData = 0;
}
}
@ -1324,7 +1332,7 @@ HANDLE X11DRV_CLIPBOARD_ExportXAString(LPWINE_CLIPDATA lpData, LPDWORD lpBytes)
UINT i, j;
UINT size;
LPWSTR uni_text;
LPSTR text, lpstr;
LPSTR text, lpstr = NULL;
*lpBytes = 0; /* Assume return has zero bytes */
@ -1333,14 +1341,14 @@ HANDLE X11DRV_CLIPBOARD_ExportXAString(LPWINE_CLIPDATA lpData, LPDWORD lpBytes)
size = WideCharToMultiByte(CP_UNIXCP, 0, uni_text, -1, NULL, 0, NULL, NULL);
text = HeapAlloc(GetProcessHeap(), 0, size);
if (!text)
return None;
if (!text) goto done;
WideCharToMultiByte(CP_UNIXCP, 0, uni_text, -1, text, size, NULL, NULL);
/* remove carriage returns */
lpstr = (char*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size-- );
if(lpstr == NULL) return None;
if(lpstr == NULL) goto done;
for(i = 0,j = 0; i < size && text[i]; i++ )
{
if( text[i] == '\r' &&
@ -1351,6 +1359,7 @@ HANDLE X11DRV_CLIPBOARD_ExportXAString(LPWINE_CLIPDATA lpData, LPDWORD lpBytes)
*lpBytes = j; /* Number of bytes in string */
done:
HeapFree(GetProcessHeap(), 0, text);
GlobalUnlock(lpData->hData32);

View File

@ -1065,13 +1065,13 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
if(flags & (ETO_CLIPPED | ETO_OPAQUE)) {
if(!lprect) {
if(flags & ETO_CLIPPED) return FALSE;
GetTextExtentPointI(hdc, glyphs, count, &sz);
done_extents = TRUE;
rc.left = x;
rc.top = y;
rc.right = x + sz.cx;
rc.bottom = y + sz.cy;
if(flags & ETO_CLIPPED) goto done;
GetTextExtentPointI(hdc, glyphs, count, &sz);
done_extents = TRUE;
rc.left = x;
rc.top = y;
rc.right = x + sz.cx;
rc.bottom = y + sz.cy;
} else {
rc = *lprect;
}
@ -1115,7 +1115,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
if(count == 0) {
retv = TRUE;
goto done;
goto done_unlock;
}
pt.x = x;
@ -1539,7 +1539,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
strikeoutWidth = underlineWidth;
} else {
otm = HeapAlloc(GetProcessHeap(), 0, nMetricsSize);
if (!otm) goto done;
if (!otm) goto done_unlock;
GetOutlineTextMetricsW(hdc, nMetricsSize, otm);
underlinePos = otm->otmsUnderscorePosition;
@ -1592,8 +1592,9 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
retv = TRUE;
done:
done_unlock:
X11DRV_UnlockDIBSection( physDev, TRUE );
done:
if(glyphs != wstr) HeapFree(GetProcessHeap(), 0, (WORD*)glyphs);
return retv;
}