Files
clang-p2996/compiler-rt/test/hwasan/TestCases/malloc-test.c
Kirill Stoimenov 01176191d2 [HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
This should keep it consistent with LSAN and ASAN,

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D143438
2023-02-07 00:35:56 +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) == 1);
free(a1);
}