Ensure readVarInt handles short buf on first byte.

It is technically possible for the Read method on a reader to return zero
bytes read with a nil error even though that behavior is "discouraged" by
the interface documenation.  This commit switches the read of the first
byte to use io.ReadFull which will always error in this case.
This commit is contained in:
Dave Collins 2013-10-06 22:06:34 -05:00
parent 5f971e10e6
commit 95ecbadb8e

View file

@ -53,7 +53,7 @@ func writeElements(w io.Writer, elements ...interface{}) error {
// readVarInt reads a variable length integer from r and returns it as a uint64.
func readVarInt(r io.Reader, pver uint32) (uint64, error) {
b := make([]byte, 1)
_, err := r.Read(b)
_, err := io.ReadFull(r, b)
if err != nil {
return 0, err
}