From 22978b6b1e5e2890bb4cb705a0f6674c2b2b6157 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 16 Jan 2020 18:48:38 +0100 Subject: 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") Reported-by: Alexey Gladkov Signed-off-by: Oleg Nesterov Signed-off-by: Luc Van Oostenryck --- show-parse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/show-parse.c b/show-parse.c index f0ea9cae..044465e9 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; } -- cgit 1.2.3-korg