Fully fix field underflow in go_to_previous_sibling (#4483)

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Max Brunsfeld 2025-06-02 15:34:25 -07:00 committed by GitHub
parent 52b719f8fb
commit 2ab9c9b590
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -135,12 +135,11 @@ static inline bool ts_tree_cursor_child_iterator_previous(
if (!extra && self->alias_sequence) {
*visible |= self->alias_sequence[self->structural_child_index];
if (self->child_index > 0) {
if (self->structural_child_index > 0) {
self->structural_child_index--;
}
}
// unsigned can underflow so compare it to child_count
if (self->child_index < self->parent.ptr->child_count) {
Subtree previous_child = ts_subtree_children(self->parent)[self->child_index];