[PATCH] D55713: Let llvm-demangle-fuzzer fuzz microsoftDemangle as well
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 10:21:08 PST 2018
thakis created this revision.
thakis added reviewers: morehouse, zturner.
Herald added a subscriber: erik.pilkington.
PR39582.
https://reviews.llvm.org/D55713
Files:
tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
Index: tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
===================================================================
--- tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
+++ tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
@@ -14,11 +14,19 @@
#include <string>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- std::string NullTerminatedString((const char *)Data, Size);
- int status = 0;
- if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr,
- nullptr, &status))
- free(demangle);
+ if (Size == 0)
+ return 0;
+
+ bool UseItanium = Data[0] < 128;
+ std::string NullTerminatedString((const char *)Data + 1, Size - 1);
+
+ if (UseItanium) {
+ free(llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr, nullptr,
+ nullptr));
+ } else {
+ free(llvm::microsoftDemangle(NullTerminatedString.c_str(), nullptr, nullptr,
+ nullptr));
+ }
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55713.178249.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/2a24d2e2/attachment.bin>
More information about the llvm-commits
mailing list