llvm-undname: Fix an assert-on-invalid

Found by oss-fuzz, fixes issues 12428 and 12429 on oss-fuzz.

Differential Revision: https://reviews.llvm.org/D60204

llvm-svn: 357647
This commit is contained in:
Nico Weber 2019-04-03 23:19:39 +00:00
parent d503567673
commit b6b1db8acb
2 changed files with 10 additions and 0 deletions

View File

@ -466,6 +466,10 @@ IdentifierNode *
Demangler::demangleFunctionIdentifierCode(StringView &MangledName) {
assert(MangledName.startsWith('?'));
MangledName = MangledName.dropFront();
if (MangledName.empty()) {
Error = true;
return nullptr;
}
if (MangledName.consumeFront("__"))
return demangleFunctionIdentifierCode(
@ -637,6 +641,7 @@ translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group) {
IdentifierNode *
Demangler::demangleFunctionIdentifierCode(StringView &MangledName,
FunctionIdentifierCodeGroup Group) {
assert(!MangledName.empty());
switch (Group) {
case FunctionIdentifierCodeGroup::Basic:
switch (char CH = MangledName.popFront()) {

View File

@ -14,3 +14,8 @@
; CHECK-EMPTY:
; CHECK-NEXT: ?@@8
; CHECK-NEXT: error: Invalid mangled name
??
; CHECK-EMPTY:
; CHECK-NEXT: ??
; CHECK-NEXT: error: Invalid mangled name