From 9d2b0e86c8338d8e8f285926752ecca642ce23da Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 6 Dec 2012 00:00:20 -0500 Subject: [PATCH] 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 --- src/cmd/ld/lib.c | 2 ++ 1 file changed, 2 insertions(+) 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();