Copy lookahead state to the stack before pushing it to the vector

Valgrind caught this. If the vector needs to grow, the original pointer will
become invalid when the buffer is realloc'd
This commit is contained in:
Max Brunsfeld 2016-01-13 13:49:16 -08:00
parent e59f6294cb
commit 1142e05873

View file

@ -335,9 +335,8 @@ static bool ts_parser__reduce(TSParser *self, int head, TSSymbol symbol,
}
LOG("split_during_reduce new_head:%d", new_head);
LookaheadState *lookahead_state =
vector_get(&self->lookahead_states, head);
vector_push(&self->lookahead_states, lookahead_state);
LookaheadState lookahead_state = *(LookaheadState *)vector_get(&self->lookahead_states, head);
vector_push(&self->lookahead_states, &lookahead_state);
}
/*