﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3753	_GUICtrlListView_SetImageList does not check for errors	MrCreatoR	Melba23	"Example:

{{{
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate(""ListView Set Image List"", 400, 300)
    $idListview = GUICtrlCreateListView("""", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)
	
    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, -1)
	
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
}}}

If third parameter ($iType) passed as not supported type (< 0 Or > 2) the script crashes.

{{{
GuiListView.au3 (3809) : ==> Variable subscript badly formatted.:
Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle))
Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[^ ERROR
}}}

I know it's wrong usage, but still should be some error checking in _GUICtrlListView_SetImageList function:

{{{
Func _GUICtrlListView_SetImageList($hWnd, $hHandle, $iType = 0)
	$iType = Int($iType) ;In case the $iType passed as other var type than int
	
	If $iType < 0 Or $iType > 2 Then
		Return SetError(1, 0, 0)
		;Or ommit the Return and set:
		$iType = 0
	EndIf
	
	Local $aType[3] = [$LVSIL_NORMAL, $LVSIL_SMALL, $LVSIL_STATE]
	
	If IsHWnd($hWnd) Then
		Return _SendMessage($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle, 0, ""wparam"", ""handle"", ""handle"")
	Else
		Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle))
	EndIf
EndFunc
}}}
"	Bug	closed	3.3.15.1	AutoIt	3.3.14.5	None	Completed		
