From f1459c278658344f581330056f974ad1376dee78 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Wed, 29 Nov 2017 19:43:11 +0000 Subject: [asan] Don't crash on fclose(NULL) It's explicitly forbidden to call fclose with NULL, but at least on Darwin, this succeeds and doesn't segfault. To maintain binary compatibility, ASan should survice fclose(NULL) as well. Differential Revision: https://reviews.llvm.org/D40053 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319347 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/asan/TestCases/Darwin/fclose.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/asan/TestCases/Darwin/fclose.c (limited to 'test') diff --git a/test/asan/TestCases/Darwin/fclose.c b/test/asan/TestCases/Darwin/fclose.c new file mode 100644 index 000000000..7807122bd --- /dev/null +++ b/test/asan/TestCases/Darwin/fclose.c @@ -0,0 +1,13 @@ +// RUN: %clang_asan %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include +#include + +int main(int argc, const char * argv[]) { + fclose(NULL); + fprintf(stderr, "Finished.\n"); + return 0; +} + +// CHECK: Finished. -- cgit v1.2.3