From e97d558ce961922845c2ecb116a2d858e3cf0ed0 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 11 Apr 2019 22:59:25 +0000 Subject: [PATCH] llvm-undname: Don't crash on incomplete enum tag manglings Found by inspection. llvm-svn: 358238 --- lib/Demangle/MicrosoftDemangle.cpp | 2 +- test/Demangle/invalid-manglings.test | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Demangle/MicrosoftDemangle.cpp b/lib/Demangle/MicrosoftDemangle.cpp index f45df9413d7..c4559ccb5e2 100644 --- a/lib/Demangle/MicrosoftDemangle.cpp +++ b/lib/Demangle/MicrosoftDemangle.cpp @@ -1907,7 +1907,7 @@ TagTypeNode *Demangler::demangleClassType(StringView &MangledName) { TT = Arena.alloc(TagKind::Class); break; case 'W': - if (MangledName.popFront() != '4') { + if (!MangledName.consumeFront('4')) { Error = true; return nullptr; } diff --git a/test/Demangle/invalid-manglings.test b/test/Demangle/invalid-manglings.test index 4c155b765a4..839218ad101 100644 --- a/test/Demangle/invalid-manglings.test +++ b/test/Demangle/invalid-manglings.test @@ -104,3 +104,8 @@ ; CHECK-EMPTY: ; CHECK-NEXT: ??C@$ ; CHECK-NEXT: error: Invalid mangled name + +?x@@3PAW +; CHECK-EMPTY: +; CHECK-NEXT: ?x@@3PAW +; CHECK-NEXT: error: Invalid mangled name