]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: skip 0-length write in cwrite
authorRuss Cox <rsc@golang.org>
Thu, 6 Dec 2012 05:00:20 +0000 (00:00 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 6 Dec 2012 05:00:20 +0000 (00:00 -0500)
The 0-length part is fine, but some callers that write 0 bytes
also pass nil as the data pointer, and the Plan 9 kernel kills the
process with 'invalid address in sys call' in that case.

R=ken2
CC=golang-dev
https://golang.org/cl/6862051

src/cmd/ld/lib.c

index 8e3a8dd690fb9b6344168672dfc5aec3b634836e..0f51e6b9f270c1fffaee16f5a8a22d44f232164f 100644 (file)
@@ -1493,6 +1493,8 @@ void
 cwrite(void *buf, int n)
 {
        cflush();
+       if(n <= 0)
+               return;
        if(write(cout, buf, n) != n) {
                diag("write error: %r");
                errorexit();