blob: dcc2bd7ef97b8203bf503eb9968a3129133ad12c [file] [log] [blame]
Matt Morehousee29452b2017-10-13 17:35:37 +00001//===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Itanium Demangler ------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Matt Morehousee29452b2017-10-13 17:35:37 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/Demangle/Demangle.h"
10
11#include <cstdint>
12#include <cstdlib>
13#include <string>
14
15extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Nico Weber93c5e2a2018-12-19 20:19:58 +000016 std::string NullTerminatedString((const char *)Data, Size);
17 int status = 0;
18 if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr,
19 nullptr, &status))
20 free(demangle);
Matt Morehousee29452b2017-10-13 17:35:37 +000021
22 return 0;
23}