Skip to content

Commit

Permalink
list index overflow short circuit order corrected
Browse files Browse the repository at this point in the history
Signed-off-by: David Zwerdling <zwerdlds@gmail.com>
  • Loading branch information
zwerdlds committed May 22, 2023
1 parent 93a1496 commit 9f01207
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/rsonpath-lib/src/engine/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,6 @@ impl<'q, 'b, I: Input> Executor<'q, 'b, I> {
R: QueryResult,
{
self.next_event = classifier.next();
if self.is_list {
if self.array_count.try_increment().is_err() {
// We can't possibly match these items, but it's not necessarily an error either.
return Ok(());
}
debug!("Incremented array count to {}", self.array_count);
}

let is_next_opening = self.next_event.map_or(false, |s| s.is_opening());

Expand All @@ -269,6 +262,13 @@ impl<'q, 'b, I: Input> Executor<'q, 'b, I> {
result.report(idx);
}

// After wildcard, check for a matching array index.
// If the index increment exceeds the field's limit, give up.
if self.is_list && self.array_count.try_increment().is_err() {
return Ok(());
}
debug!("Incremented array count to {}", self.array_count);

let match_index = self
.automaton
.has_array_index_transition_to_accepting(self.state, &self.array_count);
Expand Down

0 comments on commit 9f01207

Please sign in to comment.