From 19b776e74da62ecc8ccd4ab784091754acf2a689 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Jan 2016 13:33:05 -0800 Subject: [PATCH] Fix some errors caught by clang static analyzer --- src/runtime/parser.c | 5 ++--- src/runtime/stack.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 6e6b3f70..7ff35f25 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -81,7 +81,7 @@ static void ts_parser__breakdown_top_of_stack(TSParser *self, int head) { } free(removed_trees); - } while (last_child->child_count > 0); + } while (last_child && last_child->child_count > 0); } static void ts_parser__pop_reusable_subtree(LookaheadState *state); @@ -664,8 +664,7 @@ TSTree *ts_parser_parse(TSParser *self, TSInput input, TSTree *previous_tree) { for (;;) { TSTree *lookahead = NULL; - TSLength last_position = ts_length_zero(); - TSLength position = ts_length_zero(); + TSLength last_position, position = ts_length_zero(); self->is_split = ts_stack_head_count(self->stack) > 1; diff --git a/src/runtime/stack.c b/src/runtime/stack.c index 14f55610..ce9c0794 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -299,8 +299,8 @@ Vector ts_stack_pop(Stack *self, int head_index, int child_count, vector_push(&path->trees, &node->entry.tree); path->node = path->node->successors[0]; + PopPath path_copy = *path; for (int j = 1; j < node->successor_count; j++) { - PopPath path_copy = *path; vector_push(&self->pop_paths, &path_copy); PopPath *next_path = vector_back(&self->pop_paths); next_path->node = node->successors[j];