Opened on Mar 5, 2012 at 6:09:53 PM
#2148 closed Bug (Fixed)
Crash with _GUICtrlListBox_InsertString()
| Reported by: | Valik | Owned by: | guinness |
|---|---|---|---|
| Milestone: | 3.3.9.5 | Component: | Standard UDFs |
| Version: | 3.3.8.1 | Severity: | None |
| Keywords: | Cc: |
Description
The following code crashes Autoit (taken from #2147):
#include <GUIListBox.au3>
GUICreate("Test", 200, 320)
Local $list=GUICtrlCreateList("", 5, 2, 190, 280)
Local $button=GUICtrlCreateButton("Do It!", 40, 290, 120, 25)
GUISetState()
Global $msg
While 1
$msg = GUIGetMsg()
If $msg = -3 Then
Exit
ElseIf $msg = $button Then
_GUICtrlListBox_InsertString($list, 1) ; Crash
EndIf
WEnd
Changing the marked line to _GUICtrlListBox_InsertString($list, String(1)) fixes the crash.
Attachments (0)
Change History (4)
comment:2 by , on Mar 7, 2012 at 3:35:35 AM
Right. The crash is actually with GUICtrlSendMsg(). I imagine it looks at the type of the variant to determine what to pass to SendMessage(). Since in this example it is passing a number it gives SendMessage() a number but then the message handler tries to treat that number as a pointer to a string and boom, AutoIt crashes. I'm not sure that we can prevent the crash with GUICtrlSendMsg(). I think the best we can get here is a forced String() cast and a review of all code that uses GUICtrlSendMsg() to ensure it properly casts input to the correct type to prevent other crashes.
comment:3 by , on May 23, 2012 at 4:13:27 PM
| Component: | AutoIt → Standard UDFs |
|---|
comment:4 by , on Sep 3, 2012 at 11:22:56 PM
| Milestone: | → 3.3.9.5 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [7223] in version: 3.3.9.5

I noticed that if you use the code below it works without crashing too.