From 1b23e5471d0baddc96fd028c1a7ac3691e1fe7e4 Mon Sep 17 00:00:00 2001 From: Lior Stern Date: Tue, 31 Mar 2020 17:03:13 +0300 Subject: [PATCH] check the value of nodeptr in tnode_t::source_range. Avoids a possible nullptr dereference --- src/tnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tnode.h b/src/tnode.h index cfe3fd17b..ef2f59a1f 100644 --- a/src/tnode.h +++ b/src/tnode.h @@ -97,7 +97,7 @@ class tnode_t { uint8_t child_count() const { return nodeptr ? nodeptr->child_count : 0; } maybe_t source_range() const { - if (nodeptr->source_start == NODE_OFFSET_INVALID) return none(); + if (!nodeptr || nodeptr->source_start == NODE_OFFSET_INVALID) return none(); return source_range_t{nodeptr->source_start, nodeptr->source_length}; }