Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Worst AutoIt Bug Award


  • Please log in to reply
9 replies to this topic

#1 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,470 posts

Posted 23 May 2011 - 05:50 PM

Is this one of the worst bugs ever or what? #1844

It took me a while to see what the bug was saying...eeeeek.

Edit: IIRC SplashTextOn was one of the very early pieces of code. But still....

Edited by Jon, 23 May 2011 - 05:55 PM.








#2 Manadar

Manadar

         

  • MVPs
  • 10,805 posts

Posted 23 May 2011 - 05:57 PM

If the variant class still has the operators overloaded, I can see why someone could make an easy mistake like that.

#3 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,470 posts

Posted 23 May 2011 - 05:59 PM

I've not looked at the code yet but it's almost certainly someone casting away a string's const-ness. I'm pretty sure it wasn't me as well so I get to be preachy about it too :unsure:

#4 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 23 May 2011 - 06:12 PM

If it's casting away const it's doing so using the C cast method:
Find all "const_cast", Subfolders, Find Results 1, "Entire Solution"   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(336):       // const_cast is used here because the function expects LPVOID.  The casts are safe, though.   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(337):       InternetSetOption(hInet, INTERNET_OPTION_PROXY_USERNAME, const_cast<LPTSTR>(sProxyUser.c_str()), static_cast<DWORD>(sProxyUser.length() + 1) );   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(338):       InternetSetOption(hInet, INTERNET_OPTION_PROXY_PASSWORD, const_cast<LPTSTR>(sProxyPass.c_str()), static_cast<DWORD>(sProxyPass.length() + 1));   C:\Data\My Programs\C++\Autoit\autoit\src\CreateProcessSimple.cpp(206):   ProfileInfo.lpUserName = const_cast<LPWSTR>(lpUsername);   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(336):       // const_cast is used here because the function expects LPVOID.  The casts are safe, though.   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(337):       InternetSetOption(hInet, INTERNET_OPTION_PROXY_USERNAME, const_cast<LPTSTR>(sProxyUser.c_str()), static_cast<DWORD>(sProxyUser.length() + 1) );   C:\Data\My Programs\C++\Autoit\autoit\src\script_inet.cpp(338):       InternetSetOption(hInet, INTERNET_OPTION_PROXY_PASSWORD, const_cast<LPTSTR>(sProxyPass.c_str()), static_cast<DWORD>(sProxyPass.length() + 1));   C:\Data\My Programs\C++\Autoit\autoit\src\CreateProcessSimple.cpp(206):   ProfileInfo.lpUserName = const_cast<LPWSTR>(lpUsername);   Matching lines: 8 Matching files: 4   Total files searched: 294

I wrote all those const_cast and all of them are correct. My code is const-correct, the C API we are using is not, thus I must cast away const.

Edited by Valik, 23 May 2011 - 06:12 PM.


#5 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,277 posts

Posted 23 May 2011 - 07:01 PM

Is that worst as in the bug report being difficult or worst as in "why is the splash modifying the variable"?

#6 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,470 posts

Posted 23 May 2011 - 07:16 PM

The modifying bit.

#7 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,470 posts

Posted 23 May 2011 - 07:26 PM

LPCTSTR szTemp = _tcstok((LPTSTR)szText, _T("\r\n") );


#8 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 23 May 2011 - 09:33 PM

Ugh. _tcstok() modifies the string, that's why it doesn't take a fucking constant. Sigh. Wonder how many more stupid lines like that are in the code?

#9 Manadar

Manadar

         

  • MVPs
  • 10,805 posts

Posted 24 May 2011 - 10:15 AM

$input = "Line one" & @CRLF & "Line two" $result = StringGetFirstLine($input) MsgBox(0, "", $result) Func StringGetFirstLine($str)     SplashTextOn("", $str, -1, -1, -1, -1, 32 + 1)     SplashOff()     Return $str EndFunc

:huh2:

Amidoingitrite?

Edited by Manadar, 24 May 2011 - 10:20 AM.


#10 funkey

funkey

    New Dad

  • Active Members
  • PipPipPipPipPipPip
  • 629 posts

Posted 24 May 2011 - 10:35 AM

Funny function Mandar! :huh2:
Func StringGetFirstLine($str)     SplashTextOn("", $str, -10, -10, 0, 0, 32 + 1)     SplashOff()     Return $str EndFunc

Now it is perfect! ;)

Programming today is a race between software engineers striving to

build bigger and better idiot-proof programs, and the Universe

trying to produce bigger and better idiots.

So far, the Universe is winning.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users