Modify

#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:1 by BrewManNH <bobmarotte@…>, on Mar 6, 2012 at 9:21:38 PM

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

_GUICtrlListBox_InsertString(GUICtrlGetHandle($list), 1)

comment:2 by Valik, 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 trancexx, on May 23, 2012 at 4:13:27 PM

Component: AutoItStandard UDFs

comment:4 by guinness, on Sep 3, 2012 at 11:22:56 PM

Milestone: 3.3.9.5
Owner: set to guinness
Resolution: Fixed
Status: newclosed

Fixed by revision [7223] in version: 3.3.9.5

Modify Ticket

Action
as closed The owner will remain guinness.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.