Files
clang-p2996/compiler-rt/test/hwasan/TestCases/malloc-test.c
Evgeniy Stepanov 5abf7d90ac [hwasan] Fix new[] with zero size.
Fixes "allocator is out of memory trying to allocate 0x0 bytes" by
always allocating at least one byte.

llvm-svn: 341229
2018-08-31 17:49:49 +00:00

17 lines
375 B
C

// Test basic malloc functionality.
// RUN: %clang_hwasan %s -o %t
// RUN: %run %t
#include <stdlib.h>
#include <assert.h>
#include <sanitizer/hwasan_interface.h>
#include <sanitizer/allocator_interface.h>
int main() {
__hwasan_enable_allocator_tagging();
char *a1 = (char*)malloc(0);
assert(a1 != 0);
assert(__sanitizer_get_allocated_size(a1) == 0);
free(a1);
}