]> granicus.if.org Git - llvm/commitdiff
llvm-undame: Fix an assert-on-invalid
authorNico Weber <nicolasweber@gmx.de>
Wed, 3 Apr 2019 23:23:32 +0000 (23:23 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 3 Apr 2019 23:23:32 +0000 (23:23 +0000)
Found by oss-fuzz, fixes issue 12432 on os-fuzz.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357648 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Demangle/MicrosoftDemangle.cpp
test/Demangle/invalid-manglings.test

index b4e5cef7ac527b52ca4f8bd72d0424b09b7fc9f2..653c76e052f509918c8460cd563d4a51fbcfd122 100644 (file)
@@ -1389,9 +1389,12 @@ Demangler::demangleFullyQualifiedSymbolName(StringView &MangledName) {
     return nullptr;
 
   if (Identifier->kind() == NodeKind::StructorIdentifier) {
+    if (QN->Components->Count < 2) {
+      Error = true;
+      return nullptr;
+    }
     StructorIdentifierNode *SIN =
         static_cast<StructorIdentifierNode *>(Identifier);
-    assert(QN->Components->Count >= 2);
     Node *ClassNode = QN->Components->Nodes[QN->Components->Count - 2];
     SIN->Class = static_cast<IdentifierNode *>(ClassNode);
   }
index af919282bb825d4c695057300d7424dd77371f3b..5c26ca421bfa4a4601327d10b23b5d01d296abd5 100644 (file)
@@ -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