Skip to content

fix: ParseError Display panic on zero-length filter errors at end of input (#975)#976

Open
rustyprimus wants to merge 1 commit into
rsonquery:mainfrom
rustyprimus:fix-panic-error-end-input
Open

fix: ParseError Display panic on zero-length filter errors at end of input (#975)#976
rustyprimus wants to merge 1 commit into
rsonquery:mainfrom
rustyprimus:fix-panic-error-end-input

Conversation

@rustyprimus
Copy link
Copy Markdown

When a filter expression fails at end of input the parser emits a SyntaxError with len=0. The display code computed end_idx as start_idx + len - 1, producing an inverted byte span (end < start). This caused an arithmetic underflow in formatter::width_of_char_span when it subtracted the higher accumulated width from the lower one.

  • error/display.rs: clamp end_idx to start_idx when len == 0, in both display() and generate_notes()
  • tests/error_snapshots.rs: add regression snapshots for "$.a[?" and "$[?@.b =="

Issue

Resolves: #975

…input (rsonquery#975)

When a filter expression fails at end of input the parser emits a
SyntaxError with len=0. The display code computed end_idx as
start_idx + len - 1, producing an inverted byte span (end < start).
This caused an arithmetic underflow in formatter::width_of_char_span
when it subtracted the higher accumulated width from the lower one.

- error/display.rs: clamp end_idx to start_idx when len == 0, in both
  display() and generate_notes()
- tests/error_snapshots.rs: add regression snapshots for "$.a[?" and
  "$[?@.b =="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParseError Display panics with "attempt to subtract with overflow" on incomplete filter expressions

1 participant