summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorBen L <bobsayshilol@live.co.uk>2019-04-30 14:20:11 +0000
committerJeff Law <law@gcc.gnu.org>2019-04-30 08:20:11 -0600
commit927e42fd52ed7dee859ac85fec9dd6830d769773 (patch)
treec503ba148f17eb8c431e94bde3d3bef0e66c0d3f /libiberty
parent5bcc5a3b28d56bff2c70e5f52ce25f2cd7ee055e (diff)
cp-demangle.c (d_encoding): Guard against NULL return values from d_right (dc).
* cp-demangle.c (d_encoding): Guard against NULL return values from d_right (dc). * testsuite/demangle-expected: Add testcase. From-SVN: r270694
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog6
-rw-r--r--libiberty/cp-demangle.c10
-rw-r--r--libiberty/testsuite/demangle-expected5
3 files changed, 19 insertions, 2 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 70fc973a627..25a219a8ceb 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+2019-04-30 Ben L <bobsayshilol@live.co.uk>
+
+ * cp-demangle.c (d_encoding): Guard against NULL return values from
+ d_right (dc).
+ * testsuite/demangle-expected: Add testcase.
+
2019-04-29 Ben L <bobsayshilol@live.co.uk>
* 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 fcc2a209857..f8c4c1d365d 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 328d51a84e9..eb5264dba40 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_