1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00

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
This commit is contained in:
Russ Cox 2012-12-06 00:00:20 -05:00
parent b46d56ae72
commit 9d2b0e86c8

View File

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