show_parse: avoid null pointer dereference in do_show_type()
diff mbox series

Message ID 20200116174838.GA32100@redhat.com
State New
Headers show
Series
  • show_parse: avoid null pointer dereference in do_show_type()
Related show

Commit Message

Oleg Nesterov Jan. 16, 2020, 5:48 p.m. UTC
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")
Reported-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 show-parse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Luc Van Oostenryck Jan. 16, 2020, 7:26 p.m. UTC | #1
On Thu, Jan 16, 2020 at 06:48:38PM +0100, Oleg Nesterov wrote:
> do_show_type() checks sym->type inside the "if (!sym || ...)" block.
> 
> While at it, remove the trailing whitespaces.

Thank you! Applied and pushed. 

-- Luc

Patch
diff mbox series

diff --git a/show-parse.c b/show-parse.c
index f0ea9ca..044465e 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -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;
 	}