Gcc flags this code as having an undefined behavior: SetUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength, lpszPasswd == lpszHost ? NULL : ++lpszPasswd, lpszHost - lpszPasswd); The reason is that the order in which the parameters of a function are evaluated is not defined by the C standard. But, as I understand this code, it assumes that the expression for parameter 3 will be evaluated, together with its side-effect, before the expression for parameter 4. Changelog: * dlls/wininet/internet.c Fix invalid C code (undefined behavior) -- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ Cahn's Axiom: When all else fails, read the instructions.
Index: dlls/wininet/internet.c =================================================================== RCS file: /home/wine/wine/dlls/wininet/internet.c,v retrieving revision 1.28 diff -u -r1.28 internet.c --- dlls/wininet/internet.c 2001/12/24 20:24:37 1.28 +++ dlls/wininet/internet.c 2002/01/21 05:40:53 @@ -628,9 +628,11 @@ SetUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength, lpszUser, lpszPasswd - lpszUser); + if (lpszPasswd != lpszHost) + lpszPasswd++; SetUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength, - lpszPasswd == lpszHost ? NULL : ++lpszPasswd, + lpszPasswd == lpszHost ? NULL : lpszPasswd, lpszHost - lpszPasswd); lpszcp++; /* Advance to beginning of host */