[llvm] r357647 - llvm-undname: Fix an assert-on-invalid

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 16:19:39 PDT 2019


Author: nico
Date: Wed Apr  3 16:19:39 2019
New Revision: 357647

URL: http://llvm.org/viewvc/llvm-project?rev=357647&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
    llvm/trunk/test/Demangle/invalid-manglings.test

Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=357647&r1=357646&r2=357647&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Wed Apr  3 16:19:39 2019
@@ -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,
 IdentifierNode *
 Demangler::demangleFunctionIdentifierCode(StringView &MangledName,
                                           FunctionIdentifierCodeGroup Group) {
+  assert(!MangledName.empty());
   switch (Group) {
   case FunctionIdentifierCodeGroup::Basic:
     switch (char CH = MangledName.popFront()) {

Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=357647&r1=357646&r2=357647&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Wed Apr  3 16:19:39 2019
@@ -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




More information about the llvm-commits mailing list