40 lines · cpp
1// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t2// RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll3// RUN: %run %t %t.dll | FileCheck %s4 5#include <malloc.h>6#include <stdio.h>7 8extern "C" __declspec(dllexport)9int test_function() {10 int *p = (int*)malloc(1024 * sizeof(int));11 p[512] = 0;12 free(p);13 14 p = (int*)malloc(128);15 p = (int*)realloc(p, 2048 * sizeof(int));16 p[1024] = 0;17 free(p);18 19 p = (int*)calloc(16, sizeof(int));20 if (p[8] != 0)21 return 1;22 p[15]++;23 if (16 * sizeof(int) != _msize(p))24 return 2;25 free(p);26 27 p = new int;28 *p = 42;29 delete p;30 31 p = new int[42];32 p[15]++;33 delete [] p;34 35 printf("All ok\n");36// CHECK: All ok37 38 return 0;39}40