Skip to content

Commit

Permalink
fix: handle read errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Jan 11, 2015
1 parent 0e53685 commit dab678e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions xxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ func XXD(r io.Reader, w io.Writer) error {
r = bufio.NewReader(r)
for {
n, err := io.ReadFull(r, line)
if n == 0 || err == io.EOF {
break
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
return err
}
if n == 0 {
return nil
}

// Line offset
Expand Down Expand Up @@ -88,5 +91,4 @@ func XXD(r io.Reader, w io.Writer) error {

w.Write(newline)
}
return nil
}

0 comments on commit dab678e

Please sign in to comment.