Skip to contentSkip to conversation

show_parse: avoid null pointer dereference in do_show_type()

PATCH Applied Oleg Nesterov 2 participants 2 messages Jan 16, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 show_parse: avoid null pointer dereference in do_show_type()

do_show_type() checks sym->type inside the "if (!sym || ...)" block.

While at it, remove the trailing whitespaces.

Fixes 0fe7ebb9 ("show-parse: do not display base type's redundant specifiers")
---
 show-parse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
show-parse.c +3 -3
index f0ea9ca..044465e 100644
@@ -300,12 +300,12 @@ deeper:
 		if (as)
 			prepend(name, "%s ", show_as(as));
 
-		if (sym->type == SYM_BASETYPE || sym->type == SYM_ENUM)
+		if (sym && (sym->type == SYM_BASETYPE || sym->type == SYM_ENUM))
 			mod &= ~MOD_SPECIFIER;
 		s = modifier_string(mod);
 		len = strlen(s);
-		name->start -= len;    
-		memcpy(name->start, s, len);  
+		name->start -= len;
+		memcpy(name->start, s, len);
 		mod = 0;
 		as = NULL;
 	}
Signature · 1 line
2.5.0
#1 lore raw
Quoted 3 lines · Oleg Nesterov

do_show_type() checks sym->type inside the "if (!sym || ...)" block.

While at it, remove the trailing whitespaces.

Thank you! Applied and pushed.

-- Luc