]> git.saurik.com Git - apple/libc.git/blame_incremental - stdio/FreeBSD/puts.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdio / FreeBSD / puts.c.patch
... / ...
CommitLineData
1--- puts.c.bsdnew 2009-11-11 13:33:14.000000000 -0800
2+++ puts.c 2009-11-11 13:33:14.000000000 -0800
3@@ -44,6 +44,9 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/p
4 #include "libc_private.h"
5 #include "local.h"
6
7+// 3340719: __puts_null__ is used if string is NULL. Shared by fputs.c
8+__private_extern__ char const __puts_null__[] = "(null)";
9+
10 /*
11 * Write the given string to stdout, appending a newline.
12 */
13@@ -52,12 +55,15 @@ puts(s)
14 char const *s;
15 {
16 int retval;
17- size_t c = strlen(s);
18+ size_t c;
19 struct __suio uio;
20 struct __siov iov[2];
21
22+ // 3340719: __puts_null__ is used if s is NULL
23+ if(s == NULL)
24+ s = __puts_null__;
25 iov[0].iov_base = (void *)s;
26- iov[0].iov_len = c;
27+ iov[0].iov_len = c = strlen(s);
28 iov[1].iov_base = "\n";
29 iov[1].iov_len = 1;
30 uio.uio_resid = c + 1;