From 6f1afba0174494ee24921d0fd9b4af5144fd0169 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Thu, 2 Feb 2017 09:25:40 -0700 Subject: [PATCH] fix memory leak --- redcon.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redcon.go b/redcon.go index 0d71f31..81b27a4 100644 --- a/redcon.go +++ b/redcon.go @@ -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?