diff options
author | Kostya Serebryany <kcc@google.com> | 2016-10-13 19:06:46 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-10-13 19:06:46 +0000 |
commit | a17d23eaa7e60d54b2695e09b3aad4eb2155f629 (patch) | |
tree | 67f369e148820b6f53c484a2ebec8afe506e8892 /llvm/lib/Fuzzer/test/TraceMallocTest.cpp | |
parent | 92db01ebd7b7a3a0cc54e938b807a7e55cbddd82 (diff) | |
download | bcm5719-llvm-a17d23eaa7e60d54b2695e09b3aad4eb2155f629.tar.gz bcm5719-llvm-a17d23eaa7e60d54b2695e09b3aad4eb2155f629.zip |
[libFuzzer] add -trace_malloc= flag
llvm-svn: 284149
Diffstat (limited to 'llvm/lib/Fuzzer/test/TraceMallocTest.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/test/TraceMallocTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/TraceMallocTest.cpp b/llvm/lib/Fuzzer/test/TraceMallocTest.cpp new file mode 100644 index 00000000000..43e6950e185 --- /dev/null +++ b/llvm/lib/Fuzzer/test/TraceMallocTest.cpp @@ -0,0 +1,27 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Tests -trace_malloc +#include <assert.h> +#include <cstdint> +#include <cstdlib> +#include <cstddef> +#include <iostream> + +int *Ptr; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (!Size) return 0; + if (*Data == 1) { + delete Ptr; + Ptr = nullptr; + } else if (*Data == 2) { + delete Ptr; + Ptr = new int; + } else if (*Data == 3) { + if (!Ptr) + Ptr = new int; + } + return 0; +} + |