Skip to contentSkip to conversation

show-parse: null pointer dereference in do_show_type()

PATCH In review Davidson Francis 2 participants 2 messages May 11, 2020 – May 14, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 show-parse: null pointer dereference in do_show_type()

In do_show_type() the first if statement allows passing null pointers, which can cause a null pointer dereference in some cases, which I believe is not the desired behavior.

Fix this by changing the first if statement comparison.

---
 show-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
show-parse.c +1 -1
index 3aa06e47..11a487bc 100644
@@ -300,7 +300,7 @@ static void do_show_type(struct symbol *sym, struct type_name *name)
 	int fouled = 0;
 
 deeper:
-	if (!sym || (sym->type != SYM_NODE && sym->type != SYM_ARRAY &&
+	if (sym && (sym->type != SYM_NODE && sym->type != SYM_ARRAY &&
 		     sym->type != SYM_BITFIELD)) {
 		const char *s;
 		size_t len;
Signature · 1 line
2.11.0
#1 lore raw
Quoted 5 lines · Davidson Francis

In do_show_type() the first if statement allows passing null pointers, which can cause a null pointer dereference in some cases, which I believe is not the desired behavior.

Fix this by changing the first if statement comparison.

Oh yes ...
Applied & pushed. Thanks.

-- Luc