[wininet/ftp.c] #2 Fix some returned error codes
Paul Vriens
paul.vriens.wine at gmail.com
Sat Feb 10 10:23:15 CST 2007
Hi,
Fixes for FtpRemoveDirectory[A|W].
The fixes should also please Coverity CID-178.
Changelog
Fix some returned error codes
Cheers,
Paul.
-------------- next part --------------
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index a9f7166..6a0275c 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -1523,12 +1523,24 @@ BOOL WINAPI FtpRemoveDirectoryW(HINTERNET hFtpSession, LPCWSTR lpszDirectory)
BOOL r = FALSE;
lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession );
- if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
+ if (!lpwfs)
+ {
+ INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
goto lend;
}
+ if (!lpszDirectory)
+ {
+ INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+ goto lend;
+ }
+
hIC = lpwfs->lpAppInfo;
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
@@ -1548,8 +1560,7 @@ BOOL WINAPI FtpRemoveDirectoryW(HINTERNET hFtpSession, LPCWSTR lpszDirectory)
}
lend:
- if( lpwfs )
- WININET_Release( &lpwfs->hdr );
+ WININET_Release( &lpwfs->hdr );
return r;
}
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 50ef6cc..f389816 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -597,7 +597,6 @@ static void test_removedir(void)
SetLastError(0xdeadbeef);
bRet = FtpRemoveDirectoryA(NULL, "should_be_non_existing_deadbeef_dir");
ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
- todo_wine
ok ( GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
@@ -616,7 +615,6 @@ static void test_removedir(void)
SetLastError(0xdeadbeef);
bRet = FtpRemoveDirectoryA(hFtp, NULL);
ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
- todo_wine
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
--
1.4.4.4
More information about the wine-patches
mailing list