From: Rob Pike Date: Wed, 29 Jul 2009 22:24:42 +0000 (-0700) Subject: clean up EOF X-Git-Tag: weekly.2009-11-06~1025 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1fc0960fb4c2dbc580bdfecbfb093a503648542f;p=gostls13.git clean up EOF R=rsc DELTA=5 (0 added, 1 deleted, 4 changed) OCL=32465 CL=32467 --- diff --git a/src/pkg/gob/decoder.go b/src/pkg/gob/decoder.go index b4c0acdfa7..7e0c939300 100644 --- a/src/pkg/gob/decoder.go +++ b/src/pkg/gob/decoder.go @@ -79,10 +79,9 @@ func (dec *Decoder) Decode(e interface{}) os.Error { var n int; n, dec.state.err = io.ReadFull(dec.r, dec.buf[0:nbytes]); if dec.state.err != nil { - break; - } - if n < int(nbytes) { - dec.state.err = io.ErrUnexpectedEOF; + if dec.state.err == os.EOF { + dec.state.err = io.ErrUnexpectedEOF; + } break; } diff --git a/src/pkg/gob/encoder_test.go b/src/pkg/gob/encoder_test.go index 06420c08e3..e1c64e4dd7 100644 --- a/src/pkg/gob/encoder_test.go +++ b/src/pkg/gob/encoder_test.go @@ -240,7 +240,7 @@ func corruptDataCheck(s string, err os.Error, t *testing.T) { // Check that we survive bad data. func TestBadData(t *testing.T) { - corruptDataCheck("\x01\x01\x01", os.EOF, t); + corruptDataCheck("", os.EOF, t); corruptDataCheck("\x7Fhi", io.ErrUnexpectedEOF, t); corruptDataCheck("\x03now is the time for all good men", errBadType, t); }