diff --git a/lib/Demangle/MicrosoftDemangle.cpp b/lib/Demangle/MicrosoftDemangle.cpp index 4942e0e3655..041d327596b 100644 --- a/lib/Demangle/MicrosoftDemangle.cpp +++ b/lib/Demangle/MicrosoftDemangle.cpp @@ -2175,8 +2175,10 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) { SymbolNode *S = nullptr; if (MangledName.startsWith('?')) { S = parse(MangledName); - if (Error) + if (Error || !S->Name) { + Error = true; return nullptr; + } memorizeIdentifier(S->Name->getUnqualifiedIdentifier()); } diff --git a/test/Demangle/invalid-manglings.test b/test/Demangle/invalid-manglings.test index d64ec4f14d4..6cd025a1eec 100644 --- a/test/Demangle/invalid-manglings.test +++ b/test/Demangle/invalid-manglings.test @@ -169,3 +169,8 @@ ; CHECK-EMPTY: ; CHECK-NEXT: ??_C@_12@?z ; CHECK-NEXT: error: Invalid mangled name + +??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@ +; CHECK-EMPTY: +; CHECK-NEXT: ??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@ +; CHECK-NEXT: error: Invalid mangled name