cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
authorBen L <bobsayshilol@live.co.uk>
Tue, 30 Apr 2019 14:22:41 +0000 (14:22 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 30 Apr 2019 14:22:41 +0000 (08:22 -0600)
    * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
    * testsuite/demangle-expected: Add testcase.

From-SVN: r270695

libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/testsuite/demangle-expected

index 25a219a8cebc06b928abe54860c99c8090ec4cd1..6e9691c6bae31e43aae36931393a089a095282b0 100644 (file)
@@ -1,5 +1,8 @@
 2019-04-30  Ben L  <bobsayshilol@live.co.uk>
 
+       * 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.
index f8c4c1d365dee957f5b5a469147e8e1b999ebc30..4e5b733b548c9078c7a5f1322349b7e42b894672 100644 (file)
@@ -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
index eb5264dba40fc0dc08e6deffc49149a9cc1cd7bb..f21ed00e559a235d5d6183ac7bc44f7495e2f3ce 100644 (file)
@@ -77,6 +77,10 @@ _ZmmAtl
 _ZZaSFvOEES_
 _ZZaSFvOEES_
 _ZZaSFvOEES_
+# Could crash
+
+_ZZeqFvOEES_z
+_ZZeqFvOEES_z
 #
 # demangler/80513 Test for bogus characters after __thunk_