Home | History | Annotate | Download | only in test
      1 // This file is distributed under the University of Illinois Open Source
      2 // License. See LICENSE.TXT for details.
      3 
      4 // Tests OOM handling when there is a single large allocation.
      5 #include <assert.h>
      6 #include <cstdint>
      7 #include <cstdlib>
      8 #include <cstddef>
      9 #include <cstring>
     10 #include <iostream>
     11 #include <unistd.h>
     12 
     13 static volatile char *SinkPtr;
     14 
     15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
     16   if (Size > 0 && Data[0] == 'H') {
     17     if (Size > 1 && Data[1] == 'i') {
     18       if (Size > 2 && Data[2] == '!') {
     19         size_t kSize = (size_t)1 << 31;
     20         char *p = new char[kSize];
     21         memset(p, 0, kSize);
     22         SinkPtr = p;
     23         delete [] p;
     24       }
     25     }
     26   }
     27   return 0;
     28 }
     29 
     30