llvm-undname: Fix an assert-on-invalid, found by oss-fuzz

If a template parameter refers to a pointer to member, but the mangling
of that was a string literal instead of a real symbol, llvm-undname used
to crash instead of rejecting the input.

llvm-svn: 361402
This commit is contained in:
Nico Weber 2019-05-22 15:53:23 +00:00
parent 5a4f7cf2ff
commit 09fb2029e5
2 changed files with 8 additions and 1 deletions

View File

@ -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());
}

View File

@ -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