From 6c8dbbfe5cf50fbc86ddaccb8dec43d6e3cdd492 Mon Sep 17 00:00:00 2001 From: Ben L Date: Tue, 30 Apr 2019 14:39:14 +0000 Subject: [PATCH] d-demangle.c (dlang_parse_assocarray): Correctly handle error result. * d-demangle.c (dlang_parse_assocarray): Correctly handle error result. * testsuite/d-demangle-expected: Add testcase. From-SVN: r270700 --- libiberty/ChangeLog | 3 +++ libiberty/d-demangle.c | 5 +++++ libiberty/testsuite/d-demangle-expected | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 104f0e8b20c..0fac65bb153 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,8 @@ 2019-04-30 Ben L + * d-demangle.c (dlang_parse_assocarray): Correctly handle error result. + * testsuite/d-demangle-expected: Add testcase. + * d-demangle.c (dlang_parse_tuple): Correctly handle error result. * testsuite/d-demangle-expected: Add testcase. diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index e98118e66d2..becc402c1f8 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -1217,8 +1217,13 @@ dlang_parse_assocarray (string *decl, const char *mangled) while (elements--) { mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; + string_append (decl, ":"); 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 44a8d3b0793..490d4e14931 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1322,3 +1322,7 @@ _D7__T2fnVlS8S588888888888S6S5 --format=dlang _D1_B699999999961* _D1_B699999999961* +# Could crash +--format=dlang +_D5__T1fVHacA6666666666_ +_D5__T1fVHacA6666666666_ -- 2.30.2