From e457f92e1b16ddcd4c6955a6f99824db5a634bda Mon Sep 17 00:00:00 2001 From: Rishabh Vaish Date: Sat, 28 Feb 2026 15:53:13 -0800 Subject: [PATCH] Fix array out of bounds for large arrays by restoring skip_to_end guard In commit 871fcb3, the condition 'if skip_to_end and m < _max' was simplified to 'if skip_to_end', causing the final array grammar to be skipped when the LOOP optimization activates. Fixes #124 Signed-off-by: Rishabh Vaish --- src/cbexigen/base_coder_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cbexigen/base_coder_classes.py b/src/cbexigen/base_coder_classes.py index bd4d9c24..c2952135 100644 --- a/src/cbexigen/base_coder_classes.py +++ b/src/cbexigen/base_coder_classes.py @@ -626,7 +626,7 @@ def _add_particle_or_choice_list_to_details( add_extra = (part.max_occurs >= 1 and part.max_occurs_was_changed) skip_to_end = False # for LOOP, do not create grammar for subsequent repetitions for m in range(1, _max + 1): - if skip_to_end: + if skip_to_end and m < _max: continue if m < _max: # flag=Grammar.LOOP indicates that the _next_ grammar will be the same as this one