From 1142e058738094bedfee99d67f7ce8e248de5622 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 13 Jan 2016 13:49:16 -0800 Subject: [PATCH] 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 --- src/runtime/parser.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 92595225..6e6b3f70 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -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); } /*