Commit 1fc0960f authored by Rob Pike's avatar Rob Pike

clean up EOF

R=rsc
DELTA=5  (0 added, 1 deleted, 4 changed)
OCL=32465
CL=32467
parent 1ff5897d
...@@ -79,10 +79,9 @@ func (dec *Decoder) Decode(e interface{}) os.Error { ...@@ -79,10 +79,9 @@ func (dec *Decoder) Decode(e interface{}) os.Error {
var n int; var n int;
n, dec.state.err = io.ReadFull(dec.r, dec.buf[0:nbytes]); n, dec.state.err = io.ReadFull(dec.r, dec.buf[0:nbytes]);
if dec.state.err != nil { if dec.state.err != nil {
break; if dec.state.err == os.EOF {
} dec.state.err = io.ErrUnexpectedEOF;
if n < int(nbytes) { }
dec.state.err = io.ErrUnexpectedEOF;
break; break;
} }
......
...@@ -240,7 +240,7 @@ func corruptDataCheck(s string, err os.Error, t *testing.T) { ...@@ -240,7 +240,7 @@ func corruptDataCheck(s string, err os.Error, t *testing.T) {
// Check that we survive bad data. // Check that we survive bad data.
func TestBadData(t *testing.T) { func TestBadData(t *testing.T) {
corruptDataCheck("\x01\x01\x01", os.EOF, t); corruptDataCheck("", os.EOF, t);
corruptDataCheck("\x7Fhi", io.ErrUnexpectedEOF, t); corruptDataCheck("\x7Fhi", io.ErrUnexpectedEOF, t);
corruptDataCheck("\x03now is the time for all good men", errBadType, t); corruptDataCheck("\x03now is the time for all good men", errBadType, t);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment