fix memory leak

This commit is contained in:
Josh Baker 2017-02-02 09:25:40 -07:00
parent 582fbf0957
commit 6f1afba017
1 changed files with 5 additions and 1 deletions

View File

@ -534,7 +534,11 @@ func parseInt(b []byte) (int, error) {
func (rd *Reader) readCommands(leftover *int) ([]Command, error) {
var cmds []Command
b := rd.buf[rd.start:rd.end]
if rd.end-rd.start == 0 && len(rd.buf) > 4096 {
rd.buf = rd.buf[:4096]
rd.start = 0
rd.end = 0
}
if len(b) > 0 {
// we have data, yay!
// but is this enough data for a complete command? or multiple?