tcopen-app-templates icon indicating copy to clipboard operation
tcopen-app-templates copied to clipboard

[BUG] TcoControlZone no safeguards for arrays

Open KrisztianOlah opened this issue 1 year ago • 0 comments

Describe the bug Arrrays are declared using magic numbers, which are not checked when iterating through them; It is resulting in out of bound errors which are caught later by TcOpen with the less helpful error message of: "PlcTask(xxx): Checkbounds: Index too high (n)" Also Config is set to trigger this error by default as MaxKeymode is set to 4 while the array only has 3 elements. Furthermore, if the code is called cyclically by mistake, it will cog up Visual Studio's error pipe and VS becomes unresponsive.

To Reproduce Call Restore() or any of the add methods on any TcoControlZone with the wrong config.

Expected behavior When the out of bounds error would occur the for loops are terminated and a specific error message reported via Messenger to dignostics.

Screenshots image

KrisztianOlah avatar Aug 28 '24 08:08 KrisztianOlah