Skip to content

Potential integer overflow in Cursor::peek_n method #197

Description

@coderabbitai

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions