Page 1 of 1

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

Posted: 23 Jul 2023, 14:24
by Ragnar
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.

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

Posted: 24 Jul 2023, 06:13
by lexikos
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.

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

Posted: 24 Jul 2023, 07:33
by Ragnar
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".

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

Posted: 15 Aug 2023, 06:11
by lexikos
Fixed by v2.0.5.