[PATCH] D60202: llvm-undname: Fix a crash-on-invalid
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 3 07:57:31 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 issues 12435 and 12438 on oss-fuzz.
https://reviews.llvm.org/D60202
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
@@ -8,4 +8,9 @@
?f0@@YAXPEU?$AS_@$00$$CAD at __clang@@@Z
; CHECK-EMPTY:
; CHECK-NEXT: ?f0@@YAXPEU?$AS_@$00$$CAD at __clang@@@Z
-; CHECK-NEXT: error: Invalid mangled name
\ No newline at end of file
+; CHECK-NEXT: error: Invalid mangled name
+
+?@@8
+; CHECK-EMPTY:
+; CHECK-NEXT: ?@@8
+; CHECK-NEXT: error: Invalid mangled name
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===================================================================
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -1276,12 +1276,16 @@
return nullptr;
}
+// Returns MangledName's prefix before the first '@', or an error if
+// MangledName contains no '@' or the prefix has length 0.
StringView Demangler::demangleSimpleString(StringView &MangledName,
bool Memorize) {
StringView S;
for (size_t i = 0; i < MangledName.size(); ++i) {
if (MangledName[i] != '@')
continue;
+ if (i == 0)
+ break;
S = MangledName.substr(0, i);
MangledName = MangledName.dropFront(i + 1);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60202.193502.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/eea6d7ab/attachment.bin>
More information about the llvm-commits
mailing list