1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 // Test that libFuzzer does not crash when LLVMFuzzerMutate called from
6 // LLVMFuzzerCustomCrossOver.
15 #include "FuzzerInterface.h"
17 static volatile int sink
;
19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
20 std::string
Str(reinterpret_cast<const char *>(Data
), Size
);
21 if (Size
&& Data
[0] == '0')
26 extern "C" size_t LLVMFuzzerCustomCrossOver(const uint8_t *Data1
, size_t Size1
,
27 const uint8_t *Data2
, size_t Size2
,
28 uint8_t *Out
, size_t MaxOutSize
,
30 std::vector
<uint8_t> Buffer(MaxOutSize
* 10);
31 LLVMFuzzerMutate(Buffer
.data(), Buffer
.size(), Buffer
.size());
32 size_t Size
= std::min(Size1
, MaxOutSize
);
33 memcpy(Out
, Data1
, Size
);