Fix memory allocation problems.
This commit is contained in:
parent
d3239926c2
commit
cef19de855
|
@ -75,7 +75,7 @@ static IQueryAssociations* IQueryAssociations_Constructor(void)
|
|||
{
|
||||
IQueryAssociationsImpl* iface;
|
||||
|
||||
iface =(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
|
||||
iface = HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
|
||||
iface->lpVtbl = &IQueryAssociations_vtbl;
|
||||
iface->ref = 1;
|
||||
iface->hkeySource = NULL;
|
||||
|
@ -95,7 +95,7 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
|
|||
{
|
||||
if (lpszParam)
|
||||
{
|
||||
DWORD dwStrLen = lstrlenA(lpszParam);
|
||||
DWORD dwStrLen = MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, NULL, 0);
|
||||
|
||||
if (dwStrLen < dwLen)
|
||||
{
|
||||
|
@ -104,12 +104,12 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
|
|||
else
|
||||
{
|
||||
/* Create a new buffer big enough for the string */
|
||||
*lpszOut = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
|
||||
(dwStrLen + 1) * sizeof(WCHAR));
|
||||
*lpszOut = HeapAlloc(GetProcessHeap(), 0,
|
||||
dwStrLen * sizeof(WCHAR));
|
||||
if (!*lpszOut)
|
||||
return FALSE;
|
||||
}
|
||||
MultiByteToWideChar(0, 0, lpszParam, -1, *lpszOut, -1);
|
||||
MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, *lpszOut, dwStrLen);
|
||||
}
|
||||
else
|
||||
*lpszOut = NULL;
|
||||
|
@ -298,7 +298,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
|
|||
DWORD dwLenOut = *pcchOut;
|
||||
|
||||
if (dwLenOut >= MAX_PATH)
|
||||
lpszReturnW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
|
||||
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
|
||||
(dwLenOut + 1) * sizeof(WCHAR));
|
||||
|
||||
if (!lpszReturnW)
|
||||
|
@ -389,7 +389,7 @@ HRESULT WINAPI AssocQueryStringByKeyA(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc
|
|||
{
|
||||
DWORD dwLenOut = *pcchOut;
|
||||
if (dwLenOut >= MAX_PATH)
|
||||
lpszReturnW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
|
||||
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
|
||||
(dwLenOut + 1) * sizeof(WCHAR));
|
||||
|
||||
if (lpszReturnW)
|
||||
|
|
|
@ -1204,8 +1204,8 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue,
|
|||
}
|
||||
else
|
||||
{
|
||||
nBytesToAlloc = lstrlenA(pvData) * sizeof (CHAR);
|
||||
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc + 1);
|
||||
nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR);
|
||||
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc );
|
||||
lstrcpyA(szData, pvData);
|
||||
dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR));
|
||||
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;
|
||||
|
@ -1265,8 +1265,8 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
|
|||
}
|
||||
else
|
||||
{
|
||||
nBytesToAlloc = lstrlenW(pvData) * sizeof(WCHAR);
|
||||
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc + 1);
|
||||
nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
|
||||
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc );
|
||||
lstrcpyW(szData, pvData);
|
||||
dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) );
|
||||
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;
|
||||
|
|
|
@ -369,8 +369,8 @@ DWORD WINAPI ParseURLW(LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
|
|||
|
||||
/* see if known scheme and return indicator number */
|
||||
len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
|
||||
cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
|
||||
WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
|
||||
cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len);
|
||||
WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len, 0, 0);
|
||||
y->fcncde = URL_SCHEME_UNKNOWN;
|
||||
inet_pro = shlwapi_schemes;
|
||||
while (inet_pro->scheme_name) {
|
||||
|
@ -422,7 +422,7 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
|
|||
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
|
||||
return E_INVALIDARG;
|
||||
|
||||
base = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
|
||||
base = HeapAlloc(GetProcessHeap(), 0,
|
||||
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
|
||||
canonical = base + INTERNET_MAX_URL_LENGTH;
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ HRESULT WINAPI UrlApplySchemeA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, DWOR
|
|||
TRACE("(in %s, out size %ld, flags %08lx) using W version\n",
|
||||
debugstr_a(pszIn), *pcchOut, dwFlags);
|
||||
|
||||
in = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
|
||||
in = HeapAlloc(GetProcessHeap(), 0,
|
||||
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
|
||||
out = in + INTERNET_MAX_URL_LENGTH;
|
||||
|
||||
|
@ -1968,7 +1968,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
|
|||
LPWSTR in, out;
|
||||
DWORD ret, len, len2;
|
||||
|
||||
in = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
|
||||
in = HeapAlloc(GetProcessHeap(), 0,
|
||||
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
|
||||
out = in + INTERNET_MAX_URL_LENGTH;
|
||||
|
||||
|
|
Loading…
Reference in New Issue