compile error

This commit is contained in:
Kim "BKC" Carlbäcker 2018-01-25 09:53:07 +01:00
parent 5b17f054c5
commit 36db9e213f
1 changed files with 4 additions and 4 deletions

View File

@ -256,10 +256,10 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
var linebuf bytes.Buffer var linebuf bytes.Buffer
for { for {
peek, err := input.Peek(maxLineCharacters) peek, err := input.Peek(maxLineCharacters)
if err != bufio.ErrBufferFull { if err != nil && err != bufio.ErrBufferFull {
return nil, fmt.Errorf("PeekByte: %v", err) return nil, fmt.Errorf("PeekByte: %v", err)
} }
newLine := bytes.Index(peek, []byte("\n")); newLine := bytes.IndexByte(peek, '\n');
if newLine == -1 { if newLine == -1 {
// Instead of reading things, and copying memory around, // Instead of reading things, and copying memory around,
// we simply discard them (which doesn't allocate memory) // we simply discard them (which doesn't allocate memory)
@ -272,7 +272,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
if curFile.IsIncomplete { if curFile.IsIncomplete {
// Since we get here without hiting the above case, we've found a newline // Since we get here without hiting the above case, we've found a newline
// and only discard that part. // and only discard that part.
input.Discard(newFile) input.Discard(newLine)
break break
} }
buff := make([]byte, newLine) buff := make([]byte, newLine)
@ -287,7 +287,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
if n != newLine { if n != newLine {
return nil, fmt.Errorf("Read: could not read enough bytes %d != %d", n, newLine) return nil, fmt.Errorf("Read: could not read enough bytes %d != %d", n, newLine)
} }
n, err := linebuf.Write(buff) n, err = linebuf.Write(buff)
if err != nil { if err != nil {
return nil, fmt.Errorf("Write: %v", err) return nil, fmt.Errorf("Write: %v", err)
} }