Skip to content

Commit 09fb202

Browse files
committed
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
1 parent 5a4f7cf commit 09fb202

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/Demangle/MicrosoftDemangle.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2175,8 +2175,10 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
21752175
SymbolNode *S = nullptr;
21762176
if (MangledName.startsWith('?')) {
21772177
S = parse(MangledName);
2178-
if (Error)
2178+
if (Error || !S->Name) {
2179+
Error = true;
21792180
return nullptr;
2181+
}
21802182
memorizeIdentifier(S->Name->getUnqualifiedIdentifier());
21812183
}
21822184

llvm/test/Demangle/invalid-manglings.test

+5
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,8 @@
169169
; CHECK-EMPTY:
170170
; CHECK-NEXT: ??_C@_12@?z
171171
; CHECK-NEXT: error: Invalid mangled name
172+
173+
??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@
174+
; CHECK-EMPTY:
175+
; CHECK-NEXT: ??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@
176+
; CHECK-NEXT: error: Invalid mangled name

0 commit comments

Comments
 (0)