[PATCH] D60202: llvm-undname: Fix a crash-on-invalid
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 3 16:16:08 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357646: llvm-undname: Fix a crash-on-invalid (authored by nico, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60202?vs=193502&id=193623#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60202/new/
https://reviews.llvm.org/D60202
Files:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/test/Demangle/invalid-manglings.test
Index: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
===================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/trunk/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);
Index: llvm/trunk/test/Demangle/invalid-manglings.test
===================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test
+++ llvm/trunk/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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60202.193623.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/81bb9d13/attachment.bin>
More information about the llvm-commits
mailing list