wininet: Rename WININET_strdup_AtoW to heap_strdupAtoW and handle NULL argument in its implementation.
This commit is contained in:
parent
f598709212
commit
e09dfcfa99
|
@ -228,8 +228,8 @@ BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile,
|
||||||
LPWSTR lpwzNewRemoteFile;
|
LPWSTR lpwzNewRemoteFile;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzLocalFile = lpszLocalFile?WININET_strdup_AtoW(lpszLocalFile):NULL;
|
lpwzLocalFile = heap_strdupAtoW(lpszLocalFile);
|
||||||
lpwzNewRemoteFile = lpszNewRemoteFile?WININET_strdup_AtoW(lpszNewRemoteFile):NULL;
|
lpwzNewRemoteFile = heap_strdupAtoW(lpszNewRemoteFile);
|
||||||
ret = FtpPutFileW(hConnect, lpwzLocalFile, lpwzNewRemoteFile,
|
ret = FtpPutFileW(hConnect, lpwzLocalFile, lpwzNewRemoteFile,
|
||||||
dwFlags, dwContext);
|
dwFlags, dwContext);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzLocalFile);
|
HeapFree(GetProcessHeap(), 0, lpwzLocalFile);
|
||||||
|
@ -413,7 +413,7 @@ BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
|
||||||
LPWSTR lpwzDirectory;
|
LPWSTR lpwzDirectory;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzDirectory = lpszDirectory?WININET_strdup_AtoW(lpszDirectory):NULL;
|
lpwzDirectory = heap_strdupAtoW(lpszDirectory);
|
||||||
ret = FtpSetCurrentDirectoryW(hConnect, lpwzDirectory);
|
ret = FtpSetCurrentDirectoryW(hConnect, lpwzDirectory);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -559,7 +559,7 @@ BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
|
||||||
LPWSTR lpwzDirectory;
|
LPWSTR lpwzDirectory;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzDirectory = lpszDirectory?WININET_strdup_AtoW(lpszDirectory):NULL;
|
lpwzDirectory = heap_strdupAtoW(lpszDirectory);
|
||||||
ret = FtpCreateDirectoryW(hConnect, lpwzDirectory);
|
ret = FtpCreateDirectoryW(hConnect, lpwzDirectory);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -708,7 +708,7 @@ HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect,
|
||||||
LPWIN32_FIND_DATAW lpFindFileDataW;
|
LPWIN32_FIND_DATAW lpFindFileDataW;
|
||||||
HINTERNET ret;
|
HINTERNET ret;
|
||||||
|
|
||||||
lpwzSearchFile = lpszSearchFile?WININET_strdup_AtoW(lpszSearchFile):NULL;
|
lpwzSearchFile = heap_strdupAtoW(lpszSearchFile);
|
||||||
lpFindFileDataW = lpFindFileData?&wfd:NULL;
|
lpFindFileDataW = lpFindFileData?&wfd:NULL;
|
||||||
ret = FtpFindFirstFileW(hConnect, lpwzSearchFile, lpFindFileDataW, dwFlags, dwContext);
|
ret = FtpFindFirstFileW(hConnect, lpwzSearchFile, lpFindFileDataW, dwFlags, dwContext);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzSearchFile);
|
HeapFree(GetProcessHeap(), 0, lpwzSearchFile);
|
||||||
|
@ -1034,7 +1034,7 @@ static BOOL FTP_FtpGetCurrentDirectoryW(ftp_session_t *lpwfs, LPWSTR lpszCurrent
|
||||||
if (nResCode == 257) /* Extract directory name */
|
if (nResCode == 257) /* Extract directory name */
|
||||||
{
|
{
|
||||||
DWORD firstpos, lastpos, len;
|
DWORD firstpos, lastpos, len;
|
||||||
LPWSTR lpszResponseBuffer = WININET_strdup_AtoW(INTERNET_GetResponseBuffer());
|
LPWSTR lpszResponseBuffer = heap_strdupAtoW(INTERNET_GetResponseBuffer());
|
||||||
|
|
||||||
for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++)
|
for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++)
|
||||||
{
|
{
|
||||||
|
@ -1355,7 +1355,7 @@ HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession,
|
||||||
LPWSTR lpwzFileName;
|
LPWSTR lpwzFileName;
|
||||||
HINTERNET ret;
|
HINTERNET ret;
|
||||||
|
|
||||||
lpwzFileName = lpszFileName?WININET_strdup_AtoW(lpszFileName):NULL;
|
lpwzFileName = heap_strdupAtoW(lpszFileName);
|
||||||
ret = FtpOpenFileW(hFtpSession, lpwzFileName, fdwAccess, dwFlags, dwContext);
|
ret = FtpOpenFileW(hFtpSession, lpwzFileName, fdwAccess, dwFlags, dwContext);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzFileName);
|
HeapFree(GetProcessHeap(), 0, lpwzFileName);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1469,8 +1469,8 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN
|
||||||
LPWSTR lpwzNewFile;
|
LPWSTR lpwzNewFile;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzRemoteFile = lpszRemoteFile?WININET_strdup_AtoW(lpszRemoteFile):NULL;
|
lpwzRemoteFile = heap_strdupAtoW(lpszRemoteFile);
|
||||||
lpwzNewFile = lpszNewFile?WININET_strdup_AtoW(lpszNewFile):NULL;
|
lpwzNewFile = heap_strdupAtoW(lpszNewFile);
|
||||||
ret = FtpGetFileW(hInternet, lpwzRemoteFile, lpwzNewFile, fFailIfExists,
|
ret = FtpGetFileW(hInternet, lpwzRemoteFile, lpwzNewFile, fFailIfExists,
|
||||||
dwLocalFlagsAttribute, dwInternetFlags, dwContext);
|
dwLocalFlagsAttribute, dwInternetFlags, dwContext);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzRemoteFile);
|
HeapFree(GetProcessHeap(), 0, lpwzRemoteFile);
|
||||||
|
@ -1676,7 +1676,7 @@ BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName)
|
||||||
LPWSTR lpwzFileName;
|
LPWSTR lpwzFileName;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzFileName = lpszFileName?WININET_strdup_AtoW(lpszFileName):NULL;
|
lpwzFileName = heap_strdupAtoW(lpszFileName);
|
||||||
ret = FtpDeleteFileW(hFtpSession, lpwzFileName);
|
ret = FtpDeleteFileW(hFtpSession, lpwzFileName);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzFileName);
|
HeapFree(GetProcessHeap(), 0, lpwzFileName);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1821,7 +1821,7 @@ BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory)
|
||||||
LPWSTR lpwzDirectory;
|
LPWSTR lpwzDirectory;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzDirectory = lpszDirectory?WININET_strdup_AtoW(lpszDirectory):NULL;
|
lpwzDirectory = heap_strdupAtoW(lpszDirectory);
|
||||||
ret = FtpRemoveDirectoryW(hFtpSession, lpwzDirectory);
|
ret = FtpRemoveDirectoryW(hFtpSession, lpwzDirectory);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
HeapFree(GetProcessHeap(), 0, lpwzDirectory);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1968,8 +1968,8 @@ BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDes
|
||||||
LPWSTR lpwzDest;
|
LPWSTR lpwzDest;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
lpwzSrc = lpszSrc?WININET_strdup_AtoW(lpszSrc):NULL;
|
lpwzSrc = heap_strdupAtoW(lpszSrc);
|
||||||
lpwzDest = lpszDest?WININET_strdup_AtoW(lpszDest):NULL;
|
lpwzDest = heap_strdupAtoW(lpszDest);
|
||||||
ret = FtpRenameFileW(hFtpSession, lpwzSrc, lpwzDest);
|
ret = FtpRenameFileW(hFtpSession, lpwzSrc, lpwzDest);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzSrc);
|
HeapFree(GetProcessHeap(), 0, lpwzSrc);
|
||||||
HeapFree(GetProcessHeap(), 0, lpwzDest);
|
HeapFree(GetProcessHeap(), 0, lpwzDest);
|
||||||
|
@ -2131,7 +2131,7 @@ BOOL WINAPI FtpCommandA( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cmdW = WININET_strdup_AtoW(lpszCommand)))
|
if (!(cmdW = heap_strdupAtoW(lpszCommand)))
|
||||||
{
|
{
|
||||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -3578,7 +3578,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
|
||||||
|
|
||||||
pszToken = strtok(NULL, szSpace);
|
pszToken = strtok(NULL, szSpace);
|
||||||
if(!pszToken) continue;
|
if(!pszToken) continue;
|
||||||
lpfp->lpszName = WININET_strdup_AtoW(pszToken);
|
lpfp->lpszName = heap_strdupAtoW(pszToken);
|
||||||
TRACE("File: %s\n", debugstr_w(lpfp->lpszName));
|
TRACE("File: %s\n", debugstr_w(lpfp->lpszName));
|
||||||
}
|
}
|
||||||
/* NT way of parsing ... :
|
/* NT way of parsing ... :
|
||||||
|
@ -3627,7 +3627,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
|
||||||
|
|
||||||
pszToken = strtok(NULL, szSpace);
|
pszToken = strtok(NULL, szSpace);
|
||||||
if(!pszToken) continue;
|
if(!pszToken) continue;
|
||||||
lpfp->lpszName = WININET_strdup_AtoW(pszToken);
|
lpfp->lpszName = heap_strdupAtoW(pszToken);
|
||||||
TRACE("Name: %s\n", debugstr_w(lpfp->lpszName));
|
TRACE("Name: %s\n", debugstr_w(lpfp->lpszName));
|
||||||
}
|
}
|
||||||
/* EPLF format - http://cr.yp.to/ftp/list/eplf.html */
|
/* EPLF format - http://cr.yp.to/ftp/list/eplf.html */
|
||||||
|
|
|
@ -71,12 +71,19 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
|
static inline WCHAR *heap_strdupAtoW(const char *str)
|
||||||
{
|
{
|
||||||
int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
|
LPWSTR ret = NULL;
|
||||||
LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
||||||
|
if(str) {
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||||
|
ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
|
||||||
if(ret)
|
if(ret)
|
||||||
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
|
||||||
case INTERNET_STATUS_NAME_RESOLVED:
|
case INTERNET_STATUS_NAME_RESOLVED:
|
||||||
case INTERNET_STATUS_CONNECTING_TO_SERVER:
|
case INTERNET_STATUS_CONNECTING_TO_SERVER:
|
||||||
case INTERNET_STATUS_CONNECTED_TO_SERVER:
|
case INTERNET_STATUS_CONNECTED_TO_SERVER:
|
||||||
lpvNewInfo = WININET_strdup_AtoW(lpvStatusInfo);
|
lpvNewInfo = heap_strdupAtoW(lpvStatusInfo);
|
||||||
break;
|
break;
|
||||||
case INTERNET_STATUS_RESOLVING_NAME:
|
case INTERNET_STATUS_RESOLVING_NAME:
|
||||||
case INTERNET_STATUS_REDIRECT:
|
case INTERNET_STATUS_REDIRECT:
|
||||||
|
|
Loading…
Reference in New Issue