From: Russ Cox Date: Thu, 6 Dec 2012 05:00:20 +0000 (-0500) Subject: cmd/ld: skip 0-length write in cwrite X-Git-Tag: go1.1rc2~1707 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9d2b0e86c8338d8e8f285926752ecca642ce23da;p=gostls13.git cmd/ld: skip 0-length write in cwrite 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 --- diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 8e3a8dd690..0f51e6b9f2 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -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();