d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
authorBen L <bobsayshilol@live.co.uk>
Tue, 30 Apr 2019 14:34:52 +0000 (14:34 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 30 Apr 2019 14:34:52 +0000 (08:34 -0600)
    * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
    * testsuite/d-demangle-expected: Add testcase.

From-SVN: r270697

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

index 76a974d65261c55d13ddc2aab8731d0cc6a33479..71d446bec1c889937d38ebfae042d407eabedbcf 100644 (file)
@@ -1,5 +1,8 @@
 2019-04-30  Ben L  <bobsayshilol@live.co.uk>
 
+       * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
+       * testsuite/d-demangle-expected: Add testcase.
+
        * d-demangle.c (dlang_parse_integer): Fix stack underflow.
        * testsuite/d-demangle-expected: Add testcase.
 
index 114d9e0ef736cfc33bc61c9faea627c9c5f744dd..303d2eeafad8de1b0d2cd58d3689cc8232b42dd8 100644 (file)
@@ -1191,6 +1191,9 @@ dlang_parse_arrayliteral (string *decl, const char *mangled)
   while (elements--)
     {
       mangled = dlang_value (decl, mangled, NULL, '\0');
+      if (mangled == NULL)
+       return NULL;
+
       if (elements != 0)
        string_append (decl, ", ");
     }
index 998823899b5033131a9dc1b073acc5c81161cb55..19665f5562444f67099ba1f1d55afea9d9425c2b 100644 (file)
@@ -1310,3 +1310,7 @@ core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitte
 --format=dlang
 _D8__T2fnVa8888888888888_
 _D8__T2fnVa8888888888888_
+# Could crash
+--format=dlang
+_D5__T2fnVmA1A1A911111111D
+_D5__T2fnVmA1A1A911111111D