1 //===-- atof_fuzz.cpp -----------------------------------------------------===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 /// Fuzzing test for llvm-libc atof implementation.
11 //===----------------------------------------------------------------------===//
12 #include "src/stdlib/atof.h"
17 #include "fuzzing/stdlib/StringParserOutputDiff.h"
19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
) {
20 uint8_t *container
= new uint8_t[size
+ 1];
25 for (i
= 0; i
< size
; ++i
)
26 container
[i
] = data
[i
];
27 container
[size
] = '\0'; // Add null terminator to container.
29 StringParserOutputDiff
<double>(&LIBC_NAMESPACE::atof
, &::atof
, container
,