Commit 001a9361 authored by Peter Berg Larsen's avatar Peter Berg Larsen Committed by Alexandre Julliard

Assorted memleak fixes. Found on Michael Stefaniuc smatch list.

parent 393d16a6
...@@ -308,13 +308,13 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara ...@@ -308,13 +308,13 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
INT len; INT len;
LPWSTR dn = NULL; LPWSTR dn = NULL;
LPWSTR sn = NULL; LPWSTR sn = NULL;
HDRVR ret; HDRVR ret = 0;
if (lpDriverName) if (lpDriverName)
{ {
len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (!dn) return 0; if (!dn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len ); MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
} }
...@@ -322,14 +322,15 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara ...@@ -322,14 +322,15 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
{ {
len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (!sn) return 0; if (!sn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len ); MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
} }
ret = OpenDriver(dn, sn, lParam); ret = OpenDriver(dn, sn, lParam);
if (dn) HeapFree(GetProcessHeap(), 0, dn); done:
if (sn) HeapFree(GetProcessHeap(), 0, sn); HeapFree(GetProcessHeap(), 0, dn);
HeapFree(GetProcessHeap(), 0, sn);
return ret; return ret;
} }
......
...@@ -1360,26 +1360,27 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName, ...@@ -1360,26 +1360,27 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
{ {
LPSTR szFn = NULL; LPSTR szFn = NULL;
LPSTR sznFn = NULL; LPSTR sznFn = NULL;
UINT ret; UINT ret = MMSYSERR_NOMEM;
INT len; INT len;
if (szFileName) if (szFileName)
{ {
len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
szFn = HeapAlloc( GetProcessHeap(), 0, len ); szFn = HeapAlloc( GetProcessHeap(), 0, len );
if (!szFn) return MMSYSERR_NOMEM; if (!szFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
} }
if (szNewFileName) if (szNewFileName)
{ {
len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL );
sznFn = HeapAlloc( GetProcessHeap(), 0, len ); sznFn = HeapAlloc( GetProcessHeap(), 0, len );
if (!sznFn) return MMSYSERR_NOMEM; if (!sznFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL );
} }
ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags); ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags);
done:
HeapFree(GetProcessHeap(),0,szFn); HeapFree(GetProcessHeap(),0,szFn);
HeapFree(GetProcessHeap(),0,sznFn); HeapFree(GetProcessHeap(),0,sznFn);
return ret; return ret;
......
...@@ -2260,7 +2260,7 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara ...@@ -2260,7 +2260,7 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara
LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2); LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
if (dci16) { if (dci16) {
LPSTR str1; LPSTR str1 = NULL,str2;
INT len; INT len;
dci16->dwDCISize = sizeof(DRVCONFIGINFO16); dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
...@@ -2271,6 +2271,7 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara ...@@ -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 ); WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, str1, len, NULL, NULL );
dci16->lpszDCISectionName = MapLS( str1 ); dci16->lpszDCISectionName = MapLS( str1 );
} else { } else {
HeapFree( GetProcessHeap(), 0, dci16);
return WINMM_MAP_NOMEM; return WINMM_MAP_NOMEM;
} }
} else { } else {
...@@ -2278,11 +2279,13 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara ...@@ -2278,11 +2279,13 @@ static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lPara
} }
if (dci32->lpszDCIAliasName) { if (dci32->lpszDCIAliasName) {
len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, NULL, 0, NULL, NULL );
str1 = HeapAlloc( GetProcessHeap(), 0, len ); str2 = HeapAlloc( GetProcessHeap(), 0, len );
if (str1) { if (str2) {
WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str1, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str2, len, NULL, NULL );
dci16->lpszDCIAliasName = MapLS( str1 ); dci16->lpszDCIAliasName = MapLS( str2 );
} else { } else {
HeapFree( GetProcessHeap(), 0, str1);
HeapFree( GetProcessHeap(), 0, dci16);
return WINMM_MAP_NOMEM; return WINMM_MAP_NOMEM;
} }
} else { } else {
......
...@@ -315,11 +315,11 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol, ...@@ -315,11 +315,11 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags); TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags);
lpNewTimer = (LPWINE_TIMERENTRY)HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_TIMERENTRY)); if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
if (lpNewTimer == NULL)
return 0; return 0;
if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL) lpNewTimer = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_TIMERENTRY));
if (lpNewTimer == NULL)
return 0; return 0;
TIME_MMTimeStart(); TIME_MMTimeStart();
......
...@@ -436,7 +436,7 @@ DWORD WINAPI WsControl(DWORD protocol, ...@@ -436,7 +436,7 @@ DWORD WINAPI WsControl(DWORD protocol,
* interface are returned. */ * interface are returned. */
case CL_NL_ENTITY: case CL_NL_ENTITY:
{ {
DWORD routeTableSize, numRoutes, ndx; DWORD routeTableSize, numRoutes, ndx, ret;
PMIB_IPFORWARDTABLE table; PMIB_IPFORWARDTABLE table;
IPRouteEntry *winRouteTable = (IPRouteEntry *) pResponseInfo; IPRouteEntry *winRouteTable = (IPRouteEntry *) pResponseInfo;
...@@ -450,7 +450,11 @@ DWORD WINAPI WsControl(DWORD protocol, ...@@ -450,7 +450,11 @@ DWORD WINAPI WsControl(DWORD protocol,
table = (PMIB_IPFORWARDTABLE)calloc(1, routeTableSize); table = (PMIB_IPFORWARDTABLE)calloc(1, routeTableSize);
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; 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); memset(pResponseInfo, 0, sizeof(IPRouteEntry) * numRoutes);
for (ndx = 0; ndx < table->dwNumEntries; ndx++) for (ndx = 0; ndx < table->dwNumEntries; ndx++)
...@@ -496,8 +500,10 @@ DWORD WINAPI WsControl(DWORD protocol, ...@@ -496,8 +500,10 @@ DWORD WINAPI WsControl(DWORD protocol,
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
ret = GetIpNetTable(table, &arpTableSize, FALSE); ret = GetIpNetTable(table, &arpTableSize, FALSE);
if (ret != NO_ERROR) if (ret != NO_ERROR) {
free(table);
return ret; return ret;
}
if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) * if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) *
table->dwNumEntries) table->dwNumEntries)
{ {
...@@ -532,8 +538,10 @@ DWORD WINAPI WsControl(DWORD protocol, ...@@ -532,8 +538,10 @@ DWORD WINAPI WsControl(DWORD protocol,
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
ret = GetTcpTable(table, &tcpTableSize, FALSE); ret = GetTcpTable(table, &tcpTableSize, FALSE);
if (ret != NO_ERROR) if (ret != NO_ERROR) {
free(table);
return ret; return ret;
}
if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) * if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) *
table->dwNumEntries) table->dwNumEntries)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment