1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
3 
4 // Tests -trace_malloc
5 #include <assert.h>
6 #include <cstdint>
7 #include <cstdlib>
8 #include <cstddef>
9 #include <iostream>
10 
11 int *Ptr;
12 
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
14   if (!Size) return 0;
15   if (*Data == 1) {
16     delete Ptr;
17     Ptr = nullptr;
18   } else if (*Data == 2) {
19     delete Ptr;
20     Ptr = new int;
21   } else if (*Data == 3) {
22     if (!Ptr)
23       Ptr = new int;
24   }
25   return 0;
26 }
27 
28