mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-23 05:46:05 +00:00

I add 2 changes to make the tests work on 32 bits and on 64 bits. I change the size allocated to 0x20000000 and add the flag: -rss_limit_mb=300. Otherwise the output for 32 bits and 64 bits is different. For 64 bits the value 0xff000000 doesn't exceed kMaxAllowedMallocSize. For 32 bits, kMaxAllowedMallocSize is set to 0xc0000000, so the call to Allocate() will fail earlier printing "WARNING: AddressSanitizer failed to allocate ..." , and wont't call malloc hooks. So, we need to consider a size smaller than 2GB (so malloc doesn't fail on 32bits) and greater that the value provided by -rss_limit_mb. Because of that I use: 0x20000000. Differential Revision: https://reviews.llvm.org/D28706 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292744 91177308-0d34-0410-b5e6-96231b3b80d8
28 lines
629 B
C++
28 lines
629 B
C++
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
// Tests OOM handling.
|
|
#include <assert.h>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include <iostream>
|
|
|
|
static volatile char *SinkPtr;
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|
if (Size > 0 && Data[0] == 'H') {
|
|
if (Size > 1 && Data[1] == 'i') {
|
|
if (Size > 2 && Data[2] == '!') {
|
|
size_t kSize = 0x20000000U;
|
|
char *p = new char[kSize];
|
|
SinkPtr = p;
|
|
delete [] p;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|