]> git.saurik.com Git - apple/libc.git/blobdiff - stdio/FreeBSD/puts.c
Libc-1044.1.2.tar.gz
[apple/libc.git] / stdio / FreeBSD / puts.c
index 4b27733aa11a87afba8e4753aae38b5e8b3472d9..511cab4b5b6a2ce0073ec6f014f182f2868c7b6e 100644 (file)
@@ -44,6 +44,9 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/puts.c,v 1.11 2007/01/09 00:28:07 imp Exp
 #include "libc_private.h"
 #include "local.h"
 
+// 3340719: __puts_null__ is used if string is NULL.  Shared by fputs.c
+__private_extern__ char const __puts_null__[] = "(null)";
+
 /*
  * Write the given string to stdout, appending a newline.
  */
@@ -52,12 +55,15 @@ puts(s)
        char const *s;
 {
        int retval;
-       size_t c = strlen(s);
+       size_t c;
        struct __suio uio;
        struct __siov iov[2];
 
+       // 3340719: __puts_null__ is used if s is NULL
+       if(s == NULL)
+               s = __puts_null__;
        iov[0].iov_base = (void *)s;
-       iov[0].iov_len = c;
+       iov[0].iov_len = c = strlen(s);
        iov[1].iov_base = "\n";
        iov[1].iov_len = 1;
        uio.uio_resid = c + 1;