Hans Leidekker : wininet: Avoid a crash on an invalid handle in InternetQueryOption.

Alexandre Julliard julliard at winehq.org
Mon Jun 30 08:27:37 CDT 2008


Module: wine
Branch: master
Commit: 01e21366cb935f8e50aa2bca8a81de117e9ead48
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=01e21366cb935f8e50aa2bca8a81de117e9ead48

Author: Hans Leidekker <hans at meelstraat.net>
Date:   Sun Jun 29 16:01:45 2008 +0200

wininet: Avoid a crash on an invalid handle in InternetQueryOption.

---

 dlls/wininet/internet.c       |    2 +-
 dlls/wininet/tests/internet.c |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 388a2a9..fb71de4 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1904,7 +1904,7 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
 
             TRACE("INTERNET_OPTION_USER_AGENT\n");
 
-            if (lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET)
+            if (!lpwhh || lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET)
             {
                 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
                 return FALSE;
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index 2f88f58..8eb7cc6 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -150,6 +150,12 @@ static void test_InternetQueryOptionA(void)
   ok((hinet != 0x0),"InternetOpen Failed\n");
 
   SetLastError(0xdeadbeef);
+  retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
+  err=GetLastError();
+  ok(retval == 0,"Got wrong return value %d\n",retval);
+  ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
+
+  SetLastError(0xdeadbeef);
   len=strlen(useragent)+1;
   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
   err=GetLastError();




More information about the wine-cvs mailing list