[PATCH] wininet: Fixed signedness mess in InternetCrackUrlA

Marcus Meissner marcus at jet.franken.de
Sun May 1 08:46:02 CDT 2011


Hi,

Indirect while looking at a Coverity issue, assigning
-1 to a DWORD is bad, as DWORD is unsigned long.

At best the comparison might just break later on.

Use a temporary integer.

Ciao, Marcus
---
 dlls/wininet/internet.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index e9afb07..d8b60e3 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1333,6 +1333,7 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
     LPURL_COMPONENTSA lpUrlComponents)
 {
   DWORD nLength;
+  INT xurllen;
   URL_COMPONENTSW UCW;
   BOOL ret = FALSE;
   WCHAR *lpwszUrl, *hostname = NULL, *username = NULL, *password = NULL, *path = NULL,
@@ -1348,17 +1349,17 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
       INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
       return FALSE;
   }
-
-  if(dwUrlLength<=0)
-      dwUrlLength=-1;
-  nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
+  xurllen = dwUrlLength;
+  if(xurllen<=0)
+      xurllen=-1;
+  nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,xurllen,NULL,0);
 
   /* if dwUrlLength=-1 then nLength includes null but length to 
        InternetCrackUrlW should not include it                  */
-  if (dwUrlLength == -1) nLength--;
+  if (xurllen == -1) nLength--;
 
   lpwszUrl = heap_alloc((nLength + 1) * sizeof(WCHAR));
-  MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength + 1);
+  MultiByteToWideChar(CP_ACP,0,lpszUrl,xurllen,lpwszUrl,nLength + 1);
   lpwszUrl[nLength] = '\0';
 
   memset(&UCW,0,sizeof(UCW));
-- 
1.7.3.4



More information about the wine-patches mailing list