show_parse: avoid null pointer dereference in do_show_type()
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")
Reported-by Alexey Gladkov <[email protected]>
Signed-off-by Oleg Nesterov <[email protected]>
--- show-parse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
show-parse.c +3 -3
@@ -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
Luc Van Oostenryck
AppliedQuoted 3 lines · Oleg Nesterov
do_show_type()checkssym->typeinside the "if (!sym || ...)" block.While at it, remove the trailing whitespaces.
Thank you! Applied and pushed.
-- Luc