Description
The peek_n method in src/parser/cursor.rs (lines 145-147) uses unchecked addition self.pos + n which could potentially overflow if n is extremely large. While .get() safely returns None for out-of-bounds indices, integer overflow itself can be undefined behavior in Rust (in release mode with overflow checks disabled).
References
Context
This issue was identified during code review of the parser refactor that introduces the new cursor-based token navigation system.
Description
The
peek_nmethod insrc/parser/cursor.rs(lines 145-147) uses unchecked additionself.pos + nwhich could potentially overflow ifnis extremely large. While.get()safely returnsNonefor out-of-bounds indices, integer overflow itself can be undefined behavior in Rust (in release mode with overflow checks disabled).References
Context
This issue was identified during code review of the parser refactor that introduces the new cursor-based token navigation system.