diff options
author | Oleg Nesterov <oleg@redhat.com> | 2020-01-16 18:48:38 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-01-16 20:10:31 +0100 |
commit | 22978b6b1e5e2890bb4cb705a0f6674c2b2b6157 (patch) | |
tree | 7cb1789911d68fbde60be2a7c6a530fc002f7636 | |
parent | 1a803e7a6cf1965336d585462b4ff52bef6851a2 (diff) | |
download | sparse-22978b6b1e5e2890bb4cb705a0f6674c2b2b6157.tar.gz |
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 <gladkov.alexey@gmail.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | show-parse.c | 6 |
1 files 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; } |