Skip to content

Instantly share code, notes, and snippets.

@fd0
Created April 15, 2020 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fd0/bebba6cbed61663b170d05438f637f68 to your computer and use it in GitHub Desktop.
Save fd0/bebba6cbed61663b170d05438f637f68 to your computer and use it in GitHub Desktop.
diff --git a/chunker.go b/chunker.go
index 593be8f..5632498 100644
--- a/chunker.go
+++ b/chunker.go
@@ -2,6 +2,7 @@ package chunker
import (
"errors"
+ "fmt"
"io"
"sync"
)
@@ -265,6 +266,10 @@ func (c *Chunker) Next(data []byte) (Chunk, error) {
return Chunk{}, err
}
+ if n < 0 {
+ return Chunk{}, fmt.Errorf("ReadFull returned negative number of bytes read: %v", n)
+ }
+
c.bpos = 0
c.bmax = uint(n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment