Fix invalid read by query cursor on error nodes

🎩 @bfredl

Refs https://github.com/tree-sitter/tree-sitter/pull/448#issuecomment-536337749
This commit is contained in:
Max Brunsfeld 2019-10-01 11:28:49 -07:00
parent d40f3b96b6
commit cb87b7b76e

View file

@ -1006,7 +1006,10 @@ static inline bool ts_query_cursor__advance(TSQueryCursor *self) {
&can_have_later_siblings_with_this_field
);
TSNode node = ts_tree_cursor_current_node(&self->cursor);
TSSymbol symbol = self->query->symbol_map[ts_node_symbol(node)];
TSSymbol symbol = ts_node_symbol(node);
if (symbol != ts_builtin_sym_error) {
symbol = self->query->symbol_map[symbol];
}
// If this node is before the selected range, then avoid descending
// into it.