Matt Morehouse | b1b02b7 | 2017-10-13 17:35:37 +0000 | [diff] [blame] | 1 | //===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Itanium Demangler ------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/Demangle/Demangle.h" |
| 11 | |
| 12 | #include <cstdint> |
| 13 | #include <cstdlib> |
| 14 | #include <string> |
| 15 | |
| 16 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
Nico Weber | 576e6bc | 2018-12-19 20:19:58 +0000 | [diff] [blame] | 17 | std::string NullTerminatedString((const char *)Data, Size); |
| 18 | int status = 0; |
| 19 | if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr, |
| 20 | nullptr, &status)) |
| 21 | free(demangle); |
Matt Morehouse | b1b02b7 | 2017-10-13 17:35:37 +0000 | [diff] [blame] | 22 | |
| 23 | return 0; |
| 24 | } |