From: Ben L Date: Tue, 30 Apr 2019 14:36:24 +0000 (+0000) Subject: d-demangle.c (dlang_parse_structlit): Correctly handle error result. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dba20a51404e7addd5e76dc8b912ecaa4469ef03;p=gcc.git d-demangle.c (dlang_parse_structlit): Correctly handle error result. * d-demangle.c (dlang_parse_structlit): Correctly handle error result. * testsuite/d-demangle-expected: Add testcase. From-SVN: r270698 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 71d446bec1c..f528bb4e73e 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,8 @@ 2019-04-30 Ben L + * d-demangle.c (dlang_parse_structlit): Correctly handle error result. + * testsuite/d-demangle-expected: Add testcase. + * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result. * testsuite/d-demangle-expected: Add testcase. diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index 303d2eeafad..5590417c205 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -1246,6 +1246,9 @@ dlang_parse_structlit (string *decl, const char *mangled, const char *name) while (args--) { mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; + if (args != 0) string_append (decl, ", "); } diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 19665f55624..0a5f9da8091 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1314,3 +1314,7 @@ _D8__T2fnVa8888888888888_ --format=dlang _D5__T2fnVmA1A1A911111111D _D5__T2fnVmA1A1A911111111D +# Could crash +--format=dlang +_D7__T2fnVlS8S588888888888S6S5 +_D7__T2fnVlS8S588888888888S6S5