// libc file streams can call user-supplied functions, see fopencookie.
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, fputs, s, file);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+ if (!SANITIZER_MAC || s)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
return REAL(fputs)(s, file);
}
#define INIT_FPUTS COMMON_INTERCEPT_FUNCTION(fputs)
// libc file streams can call user-supplied functions, see fopencookie.
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, puts, s);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+ if (!SANITIZER_MAC || s)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
return REAL(puts)(s);
}
#define INIT_PUTS COMMON_INTERCEPT_FUNCTION(puts)
--- /dev/null
+// On Darwin, the man page states that "both fputs() and puts() print `(null)'
+// if str is NULL."
+//
+// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s
+// CHECK: {{^\(null\)---\(null\)$}}
+
+#include <assert.h>
+#include <stdio.h>
+
+int main(void) {
+ assert(fputs(NULL, stdout) >= 0);
+ fputs("---", stdout);
+ assert(puts(NULL) >= 0);
+
+ return 0;
+}