[overlay] ticket #10719 add safety checks
[overlay] fix indexing in range which was wrong for open polygons (ticket #10719)