Opened 12 years ago

Closed 12 years ago

#2148 closed Bug (Fixed)

Crash with _GUICtrlListBox_InsertString()

Reported by: Valik Owned by: guinness
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:


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)

Global $msg
While 1
	$msg = GUIGetMsg()
	If $msg = -3 Then
	ElseIf $msg = $button Then
		_GUICtrlListBox_InsertString($list, 1)	; Crash

Changing the marked line to _GUICtrlListBox_InsertString($list, String(1)) fixes the crash.

Attachments (0)

Change History (4)

comment:1 Changed 12 years ago by BrewManNH <bobmarotte@…>

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

_GUICtrlListBox_InsertString(GUICtrlGetHandle($list), 1)

comment:2 Changed 12 years ago by Valik

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 Changed 12 years ago by trancexx

  • Component changed from AutoIt to Standard UDFs

comment:4 Changed 12 years ago by guinness

  • Milestone set to
  • Owner set to guinness
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [7223] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain guinness.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.