xref: /third_party/json/tests/thirdparty/Fuzzer/test/TraceMallocTest.cpp (revision c5f01b2f)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/json/tests/thirdparty/Fuzzer/test/
1c5f01b2fSopenharmony_ci// This file is distributed under the University of Illinois Open Source
2c5f01b2fSopenharmony_ci// License. See LICENSE.TXT for details.
3c5f01b2fSopenharmony_ci
4c5f01b2fSopenharmony_ci// Tests -trace_malloc
5c5f01b2fSopenharmony_ci#include <assert.h>
6c5f01b2fSopenharmony_ci#include <cstdint>
7c5f01b2fSopenharmony_ci#include <cstdlib>
8c5f01b2fSopenharmony_ci#include <cstddef>
9c5f01b2fSopenharmony_ci#include <iostream>
10c5f01b2fSopenharmony_ci
11c5f01b2fSopenharmony_ciint *Ptr;
12c5f01b2fSopenharmony_ci
13c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14c5f01b2fSopenharmony_ci  if (!Size) return 0;
15c5f01b2fSopenharmony_ci  if (*Data == 1) {
16c5f01b2fSopenharmony_ci    delete Ptr;
17c5f01b2fSopenharmony_ci    Ptr = nullptr;
18c5f01b2fSopenharmony_ci  } else if (*Data == 2) {
19c5f01b2fSopenharmony_ci    delete Ptr;
20c5f01b2fSopenharmony_ci    Ptr = new int;
21c5f01b2fSopenharmony_ci  } else if (*Data == 3) {
22c5f01b2fSopenharmony_ci    if (!Ptr)
23c5f01b2fSopenharmony_ci      Ptr = new int;
24c5f01b2fSopenharmony_ci  }
25c5f01b2fSopenharmony_ci  return 0;
26c5f01b2fSopenharmony_ci}
27c5f01b2fSopenharmony_ci
28

Indexes created Thu Nov 07 10:32:03 CST 2024