mirror of https://github.com/tidwall/redcon.git
fix memory leak
This commit is contained in:
parent
582fbf0957
commit
6f1afba017
|
@ -534,7 +534,11 @@ func parseInt(b []byte) (int, error) {
|
||||||
func (rd *Reader) readCommands(leftover *int) ([]Command, error) {
|
func (rd *Reader) readCommands(leftover *int) ([]Command, error) {
|
||||||
var cmds []Command
|
var cmds []Command
|
||||||
b := rd.buf[rd.start:rd.end]
|
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 {
|
if len(b) > 0 {
|
||||||
// we have data, yay!
|
// we have data, yay!
|
||||||
// but is this enough data for a complete command? or multiple?
|
// but is this enough data for a complete command? or multiple?
|
||||||
|
|
Loading…
Reference in New Issue