From: law Date: Tue, 30 Apr 2019 14:20:11 +0000 (+0000) Subject: * cp-demangle.c (d_encoding): Guard against NULL return values from X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c46137ca6fc3cc2ca348700926a1d8b9c143ae3;p=thirdparty%2Fgcc.git * cp-demangle.c (d_encoding): Guard against NULL return values from d_right (dc). * testsuite/demangle-expected: Add testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270694 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 70fc973a627d..25a219a8cebc 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2019-04-30 Ben L + + * cp-demangle.c (d_encoding): Guard against NULL return values from + d_right (dc). + * testsuite/demangle-expected: Add testcase. + 2019-04-29 Ben L * cp-demangle.c (d_expression_1): Don't peek ahead unless the current diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index fcc2a2098570..f8c4c1d365de 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1330,8 +1330,14 @@ d_encoding (struct d_info *di, int top_level) really apply here; this happens when parsing a class which is local to a function. */ if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME) - while (is_fnqual_component_type (d_right (dc)->type)) - d_right (dc) = d_left (d_right (dc)); + { + while (d_right (dc) != NULL + && is_fnqual_component_type (d_right (dc)->type)) + d_right (dc) = d_left (d_right (dc)); + + if (d_right (dc) == NULL) + dc = NULL; + } } else { diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 328d51a84e99..eb5264dba40f 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -72,6 +72,11 @@ _Q8ccQ4M2e. _ZmmAtl _ZmmAtl +# Could crash +--no-params +_ZZaSFvOEES_ +_ZZaSFvOEES_ +_ZZaSFvOEES_ # # demangler/80513 Test for bogus characters after __thunk_