comparison projects/compiler-rt/test/fuzzer/TraceMallocTest.cpp @ 131:f476a9ba4795

http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
author mir3636
date Fri, 16 Feb 2018 21:02:11 +0900
parents
children
comparison
equal deleted inserted replaced
130:cc94f0a83282 131:f476a9ba4795
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 <cstddef>
7 #include <cstdint>
8 #include <cstdlib>
9 #include <iostream>
10
11 int *Ptr;
12
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