From da099d0bbe8b1ca9eabfadac8f7fb8e16bae1ff2 Mon Sep 17 00:00:00 2001 From: Phil Turnbull Date: Wed, 14 Jun 2017 10:55:04 -0400 Subject: [PATCH] Prevent NULL pointer dereference in parser__repair_error_callback Because repair_reduction_count is unsigned, the default of '-1' is 0xffffffff and will cause the loop to be entered if repair_reduction_count is NULL: src/runtime/parser.c:691:11: warning: Dereference of null pointer if (repair_reductions[j].params.symbol == repair->symbol) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/runtime/parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index ef9cd31c..a7198778 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -656,7 +656,7 @@ static StackIterateAction parser__repair_error_callback( StackIterateAction result = StackIterateNone; uint32_t last_repair_count = -1; - uint32_t repair_reduction_count = -1; + uint32_t repair_reduction_count = 0; const TSParseAction *repair_reductions = NULL; for (uint32_t i = 0; i < repairs->size; i++) {