Coverage Report

Created: 2026-07-16 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pybind_fuzzer.cc
Line
Count
Source
1
/* Copyright 2023 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
13
#include <fuzzer/FuzzedDataProvider.h>
14
#include <iostream>
15
#include <string>
16
#include "pybind11/embed.h"
17
#include "pybind11/pybind11.h"
18
19
namespace py = pybind11;
20
21
0
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
22
0
  FuzzedDataProvider fdp(data, size);
23
24
0
  static py::scoped_interpreter guard{};
25
0
  try {
26
0
    auto locals = py::dict();
27
0
    py::exec(fdp.ConsumeRandomLengthString().c_str(), py::globals(), locals);
28
0
  } catch (pybind11::error_already_set &e) {
29
0
  }
30
31
0
  try {
32
0
    py::object os = py::module_::import("os");
33
0
    py::object makedirs = os.attr(fdp.ConsumeRandomLengthString().c_str());
34
0
  } catch (py::error_already_set &e) {
35
0
  }
36
37
0
  try {
38
0
    py::tuple args =
39
0
        py::make_tuple(fdp.ConsumeRandomLengthString().c_str(), py::none());
40
0
    py::object Decimal = py::module_::import("decimal").attr("Decimal");
41
0
    py::object pi = Decimal(fdp.ConsumeRandomLengthString().c_str());
42
0
    py::object exp_pi = pi.attr(fdp.ConsumeRandomLengthString().c_str())();
43
0
  } catch (py::error_already_set &e) {
44
0
  }
45
46
0
  try {
47
0
    py::object obj = py::str(fdp.ConsumeRandomLengthString().c_str());
48
0
  } catch (py::error_already_set &e) {
49
0
  }
50
0
  return 0;
51
0
}