[v2.0.4] LV.Add/Insert/Modify: Critical error when passing minimum parameters Topic is solved

Report problems with documented functionality
User avatar
Ragnar
Posts: 764
Joined: 30 Sep 2013, 15:25

[v2.0.4] LV.Add/Insert/Modify: Critical error when passing minimum parameters

23 Jul 2023, 14:24

The following code:

Code: Select all

#Requires AutoHotkey v2
G := Gui()
LV := G.Add("ListView", "r20 w700", ["a","b"])
LV.Insert(1,)
; LV.Insert(1, unset) ; this works
G.Show()
causes the following error:

Code: Select all

Critical Error: Invalid memory read/write.

	002: G := Gui()
	003: LV := G.Add("ListView", "r20 w700", ["a","b"])
▶	004: LV.Insert(1,)
	006: G.Show()
	007: Exit

The program is now unstable and will exit.
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0.4] Critical error if LV.Add/Insert/Modify param list ends with a comma

24 Jul 2023, 06:13

That doesn't make sense, because trailing commas are ignored.

As expected, the crash occurs even without the comma, and does not occur for LV.Insert(1, unset, ) or any other case with a trailing comma but more than one explicit parameter.

If Options and all subsequent parameters are completely absent, the count for the variadic Col parameter ends up negative, and the non-zero value is assumed to mean there is at least one parameter.
User avatar
Ragnar
Posts: 764
Joined: 30 Sep 2013, 15:25

Re: [v2.0.4] LV.Add/Insert/Modify: Critical error when passing minimum parameters

24 Jul 2023, 07:33

Well, at least the issue was found :)

For clarity, I have changed the thread title from "Critical error if LV.Add/Insert/Modify param list ends with a comma" to "LV.Add/Insert/Modify: Critical error when passing minimum parameters".

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 34 guests