Skip to content

Commit ddf3952

Browse files
ylnJulian Lettner
authored andcommitted
[ASan] Support {f}puts(NULL) on Darwin, part 2
Add braces around macro `{ MACRO(); }` to guard against macros that expand to multiple statements. llvm-svn: 366488 (cherry picked from commit be7a7ae)
1 parent c554b3b commit ddf3952

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,8 +1241,9 @@ INTERCEPTOR_WITH_SUFFIX(int, fputs, char *s, void *file) {
12411241
// libc file streams can call user-supplied functions, see fopencookie.
12421242
void *ctx;
12431243
COMMON_INTERCEPTOR_ENTER(ctx, fputs, s, file);
1244-
if (!SANITIZER_MAC || s)
1244+
if (!SANITIZER_MAC || s) { // `fputs(NULL, file)` is supported on Darwin.
12451245
COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
1246+
}
12461247
return REAL(fputs)(s, file);
12471248
}
12481249
#define INIT_FPUTS COMMON_INTERCEPT_FUNCTION(fputs)
@@ -1255,8 +1256,9 @@ INTERCEPTOR(int, puts, char *s) {
12551256
// libc file streams can call user-supplied functions, see fopencookie.
12561257
void *ctx;
12571258
COMMON_INTERCEPTOR_ENTER(ctx, puts, s);
1258-
if (!SANITIZER_MAC || s)
1259+
if (!SANITIZER_MAC || s) { // `puts(NULL)` is supported on Darwin.
12591260
COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
1261+
}
12601262
return REAL(puts)(s);
12611263
}
12621264
#define INIT_PUTS COMMON_INTERCEPT_FUNCTION(puts)

0 commit comments

Comments
 (0)