summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-04-03 23:19:39 +0000
committerNico Weber <nicolasweber@gmx.de>2019-04-03 23:19:39 +0000
commit321de48a94096f83a4be5164bce462e6285413c7 (patch)
tree077c668ee2ff861d0bb7b97faad9e47181d396d2
parentc7444ddfe5791bff8cfb3369df84669d0af8e800 (diff)
downloadbcm5719-llvm-321de48a94096f83a4be5164bce462e6285413c7.tar.gz
bcm5719-llvm-321de48a94096f83a4be5164bce462e6285413c7.zip
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 llvm-svn: 357647
-rw-r--r--llvm/lib/Demangle/MicrosoftDemangle.cpp5
-rw-r--r--llvm/test/Demangle/invalid-manglings.test5
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index b8e39c41527..b4e5cef7ac5 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -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, FunctionIdentifierCodeGroup Group) {
IdentifierNode *
Demangler::demangleFunctionIdentifierCode(StringView &MangledName,
FunctionIdentifierCodeGroup Group) {
+ assert(!MangledName.empty());
switch (Group) {
case FunctionIdentifierCodeGroup::Basic:
switch (char CH = MangledName.popFront()) {
diff --git a/llvm/test/Demangle/invalid-manglings.test b/llvm/test/Demangle/invalid-manglings.test
index 6883a46d8d3..af919282bb8 100644
--- a/llvm/test/Demangle/invalid-manglings.test
+++ b/llvm/test/Demangle/invalid-manglings.test
@@ -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
OpenPOWER on IntegriCloud