Index: llvm/lib/Demangle/MicrosoftDemangle.cpp =================================================================== --- llvm/lib/Demangle/MicrosoftDemangle.cpp +++ llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -1389,9 +1389,12 @@ return nullptr; if (Identifier->kind() == NodeKind::StructorIdentifier) { + if (QN->Components->Count < 2) { + Error = true; + return nullptr; + } StructorIdentifierNode *SIN = static_cast(Identifier); - assert(QN->Components->Count >= 2); Node *ClassNode = QN->Components->Nodes[QN->Components->Count - 2]; SIN->Class = static_cast(ClassNode); } Index: llvm/test/Demangle/invalid-manglings.test =================================================================== --- llvm/test/Demangle/invalid-manglings.test +++ llvm/test/Demangle/invalid-manglings.test @@ -19,3 +19,8 @@ ; CHECK-EMPTY: ; CHECK-NEXT: ?? ; CHECK-NEXT: error: Invalid mangled name + +??0@ +; CHECK-EMPTY: +; CHECK-NEXT: ??0@ +; CHECK-NEXT: error: Invalid mangled name