[compiler-rt] r366488 - [ASan] Support `{f}puts(NULL)` on Darwin, part 2

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 13:14:50 PDT 2019


Author: yln
Date: Thu Jul 18 13:14:50 2019
New Revision: 366488

URL: http://llvm.org/viewvc/llvm-project?rev=366488&view=rev
Log:
[ASan] Support `{f}puts(NULL)` on Darwin, part 2

Add braces around macro `{ MACRO(); }` to guard against macros that
expand to multiple statements.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=366488&r1=366487&r2=366488&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Jul 18 13:14:50 2019
@@ -1241,8 +1241,9 @@ INTERCEPTOR_WITH_SUFFIX(int, fputs, char
   // libc file streams can call user-supplied functions, see fopencookie.
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, fputs, s, file);
-  if (!SANITIZER_MAC || s)
+  if (!SANITIZER_MAC || s) {  // `fputs(NULL, file)` is supported on Darwin.
     COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+  }
   return REAL(fputs)(s, file);
 }
 #define INIT_FPUTS COMMON_INTERCEPT_FUNCTION(fputs)
@@ -1255,8 +1256,9 @@ INTERCEPTOR(int, puts, char *s) {
   // libc file streams can call user-supplied functions, see fopencookie.
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, puts, s);
-  if (!SANITIZER_MAC || s)
+  if (!SANITIZER_MAC || s) {  // `puts(NULL)` is supported on Darwin.
     COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+  }
   return REAL(puts)(s);
 }
 #define INIT_PUTS COMMON_INTERCEPT_FUNCTION(puts)




More information about the llvm-commits mailing list