summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-05-22 15:53:23 +0000
committerNico Weber <nicolasweber@gmx.de>2019-05-22 15:53:23 +0000
commit09fb2029e5420e12a3f9c47d8c55b2d715df0e05 (patch)
tree27f6b68d3f0b8ebb17db454666d5ceb4b4d5f963 /llvm
parent5a4f7cf2ff3fc15d82ca062ee64dd8bd01a68883 (diff)
downloadbcm5719-llvm-09fb2029e5420e12a3f9c47d8c55b2d715df0e05.tar.gz
bcm5719-llvm-09fb2029e5420e12a3f9c47d8c55b2d715df0e05.zip
llvm-undname: Fix an assert-on-invalid, found by oss-fuzz
If a template parameter refers to a pointer to member, but the mangling of that was a string literal instead of a real symbol, llvm-undname used to crash instead of rejecting the input. llvm-svn: 361402
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Demangle/MicrosoftDemangle.cpp4
-rw-r--r--llvm/test/Demangle/invalid-manglings.test5
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index 4942e0e3655..041d327596b 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -2175,8 +2175,10 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
SymbolNode *S = nullptr;
if (MangledName.startsWith('?')) {
S = parse(MangledName);
- if (Error)
+ if (Error || !S->Name) {
+ Error = true;
return nullptr;
+ }
memorizeIdentifier(S->Name->getUnqualifiedIdentifier());
}
diff --git a/llvm/test/Demangle/invalid-manglings.test b/llvm/test/Demangle/invalid-manglings.test
index d64ec4f14d4..6cd025a1eec 100644
--- a/llvm/test/Demangle/invalid-manglings.test
+++ b/llvm/test/Demangle/invalid-manglings.test
@@ -169,3 +169,8 @@
; CHECK-EMPTY:
; CHECK-NEXT: ??_C@_12@?z
; CHECK-NEXT: error: Invalid mangled name
+
+??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@
+; CHECK-EMPTY:
+; CHECK-NEXT: ??$foo@$1??_C@_02PCEFGMJL@hi?$AA@@
+; CHECK-NEXT: error: Invalid mangled name
OpenPOWER on IntegriCloud