From: Ben L Date: Tue, 30 Apr 2019 14:34:52 +0000 (+0000) Subject: d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=80b1ab1579887f21a2d0d34abbe726cbff2706df;p=gcc.git d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result. * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result. * testsuite/d-demangle-expected: Add testcase. From-SVN: r270697 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 76a974d6526..71d446bec1c 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,8 @@ 2019-04-30 Ben L + * 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. diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index 114d9e0ef73..303d2eeafad 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -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, ", "); } diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 998823899b5..19665f55624 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -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