[PATCH] D60204: llvm-undname: Fix an assert-on-invalid
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 3 08:14:40 PDT 2019
thakis created this revision.
thakis added a reviewer: zturner.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Found by oss-fuzz, fixes issue 12428 on oss-fuzz.
https://reviews.llvm.org/D60204
Files:
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/test/Demangle/invalid-manglings.test
Index: llvm/test/Demangle/invalid-manglings.test
===================================================================
--- llvm/test/Demangle/invalid-manglings.test
+++ 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
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===================================================================
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -466,6 +466,10 @@
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 @@
IdentifierNode *
Demangler::demangleFunctionIdentifierCode(StringView &MangledName,
FunctionIdentifierCodeGroup Group) {
+ assert(!MangledName.empty());
switch (Group) {
case FunctionIdentifierCodeGroup::Basic:
switch (char CH = MangledName.popFront()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60204.193507.patch
Type: text/x-patch
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/95a18ec1/attachment.bin>
More information about the llvm-commits
mailing list