summaryrefslogtreecommitdiff
path: root/libiberty/cp-demangle.c
diff options
context:
space:
mode:
authorBen L <bobsayshilol@live.co.uk>2019-04-30 14:22:41 +0000
committerJeff Law <law@gcc.gnu.org>2019-04-30 08:22:41 -0600
commit80024f3180b9c4c904cd65323e1d1333cf19d1fe (patch)
treea315c6b8b02c4fb989e8fefed7e4b5ff6d0bdaff /libiberty/cp-demangle.c
parent927e42fd52ed7dee859ac85fec9dd6830d769773 (diff)
downloadgcc-80024f3180b9c4c904cd65323e1d1333cf19d1fe.tar.gz
cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
* cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'. * testsuite/demangle-expected: Add testcase. From-SVN: r270695
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r--libiberty/cp-demangle.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index f8c4c1d365d..4e5b733b548 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