From: law Date: Tue, 30 Apr 2019 14:22:41 +0000 (+0000) Subject: * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89b49dd23b89c27af054369d96637cf22195d9da;p=thirdparty%2Fgcc.git * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'. * testsuite/demangle-expected: Add testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270695 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 25a219a8cebc..6e9691c6bae3 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,8 @@ 2019-04-30 Ben L + * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'. + * testsuite/demangle-expected: Add testcase. + * cp-demangle.c (d_encoding): Guard against NULL return values from d_right (dc). * testsuite/demangle-expected: Add testcase. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index f8c4c1d365de..4e5b733b548c 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -4767,12 +4767,8 @@ d_print_comp_inner (struct d_print_info *dpi, int options, typed_name = d_right (typed_name); if (typed_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) typed_name = typed_name->u.s_unary_num.sub; - if (typed_name == NULL) - { - d_print_error (dpi); - return; - } - while (is_fnqual_component_type (typed_name->type)) + while (typed_name != NULL + && is_fnqual_component_type (typed_name->type)) { if (i >= sizeof adpm / sizeof adpm[0]) { @@ -4791,6 +4787,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options, typed_name = d_left (typed_name); } + if (typed_name == NULL) + { + d_print_error (dpi); + return; + } } /* If typed_name is a template, then it applies to the diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index eb5264dba40f..f21ed00e559a 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -77,6 +77,10 @@ _ZmmAtl _ZZaSFvOEES_ _ZZaSFvOEES_ _ZZaSFvOEES_ +# Could crash + +_ZZeqFvOEES_z +_ZZeqFvOEES_z # # demangler/80513 Test for bogus characters after __thunk_