Assorted memleak fixes. Found on Michael Stefaniuc smatch list.

This commit is contained in:
Peter Berg Larsen 2005-03-11 12:50:27 +00:00 committed by Alexandre Julliard
parent 393d16a67f
commit 001a936176
5 changed files with 33 additions and 20 deletions

View File

@ -308,13 +308,13 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
INT len;
LPWSTR dn = NULL;
LPWSTR sn = NULL;
HDRVR ret;
HDRVR ret = 0;
if (lpDriverName)
{
len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (!dn) return 0;
if (!dn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
}
@ -322,14 +322,15 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
{
len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (!sn) return 0;
if (!sn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
}
ret = OpenDriver(dn, sn, lParam);
if (dn) HeapFree(GetProcessHeap(), 0, dn);
if (sn) HeapFree(GetProcessHeap(), 0, sn);
done:
HeapFree(GetProcessHeap(), 0, dn);
HeapFree(GetProcessHeap(), 0, sn);
return ret;
}

View File

@ -1360,26 +1360,27 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
{
LPSTR szFn = NULL;
LPSTR sznFn = NULL;
UINT ret;
UINT ret = MMSYSERR_NOMEM;
INT len;
if (szFileName)
{
len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
szFn = HeapAlloc( GetProcessHeap(), 0, len );
if (!szFn) return MMSYSERR_NOMEM;
if (!szFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
}
if (szNewFileName)
{
len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL );
sznFn = HeapAlloc( GetProcessHeap(), 0, len );
if (!sznFn) return MMSYSERR_NOMEM;
if (!sznFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL );
}
ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags);
done:
HeapFree(GetProcessHeap(),0,szFn);
HeapFree(GetProcessHeap(),0,sznFn);
return ret;

View File

@ -2260,7 +2260,7 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara
LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
if (dci16) {
LPSTR str1;
LPSTR str1 = NULL,str2;
INT len;
dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
@ -2271,6 +2271,7 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara
WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, str1, len, NULL, NULL );
dci16->lpszDCISectionName = MapLS( str1 );
} else {
HeapFree( GetProcessHeap(), 0, dci16);
return WINMM_MAP_NOMEM;
}
} else {
@ -2278,11 +2279,13 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara
}
if (dci32->lpszDCIAliasName) {
len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, NULL, 0, NULL, NULL );
str1 = HeapAlloc( GetProcessHeap(), 0, len );
if (str1) {
WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str1, len, NULL, NULL );
dci16->lpszDCIAliasName = MapLS( str1 );
str2 = HeapAlloc( GetProcessHeap(), 0, len );
if (str2) {
WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str2, len, NULL, NULL );
dci16->lpszDCIAliasName = MapLS( str2 );
} else {
HeapFree( GetProcessHeap(), 0, str1);
HeapFree( GetProcessHeap(), 0, dci16);
return WINMM_MAP_NOMEM;
}
} else {

View File

@ -315,11 +315,11 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags);
lpNewTimer = (LPWINE_TIMERENTRY)HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_TIMERENTRY));
if (lpNewTimer == NULL)
if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
return 0;
if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
lpNewTimer = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_TIMERENTRY));
if (lpNewTimer == NULL)
return 0;
TIME_MMTimeStart();

View File

@ -436,7 +436,7 @@ DWORD WINAPI WsControl(DWORD protocol,
* interface are returned. */
case CL_NL_ENTITY:
{
DWORD routeTableSize, numRoutes, ndx;
DWORD routeTableSize, numRoutes, ndx, ret;
PMIB_IPFORWARDTABLE table;
IPRouteEntry *winRouteTable = (IPRouteEntry *) pResponseInfo;
@ -450,7 +450,11 @@ DWORD WINAPI WsControl(DWORD protocol,
table = (PMIB_IPFORWARDTABLE)calloc(1, routeTableSize);
if (!table)
return ERROR_NOT_ENOUGH_MEMORY;
GetIpForwardTable(table, &routeTableSize, FALSE);
ret = GetIpForwardTable(table, &routeTableSize, FALSE);
if (ret != NO_ERROR) {
free(table);
return ret;
}
memset(pResponseInfo, 0, sizeof(IPRouteEntry) * numRoutes);
for (ndx = 0; ndx < table->dwNumEntries; ndx++)
@ -496,8 +500,10 @@ DWORD WINAPI WsControl(DWORD protocol,
if (!table)
return ERROR_NOT_ENOUGH_MEMORY;
ret = GetIpNetTable(table, &arpTableSize, FALSE);
if (ret != NO_ERROR)
if (ret != NO_ERROR) {
free(table);
return ret;
}
if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) *
table->dwNumEntries)
{
@ -532,8 +538,10 @@ DWORD WINAPI WsControl(DWORD protocol,
if (!table)
return ERROR_NOT_ENOUGH_MEMORY;
ret = GetTcpTable(table, &tcpTableSize, FALSE);
if (ret != NO_ERROR)
if (ret != NO_ERROR) {
free(table);
return ret;
}
if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) *
table->dwNumEntries)
{