From cfabd4f6666d36106b9e3c65ca815fe964eb0b84 Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 22 Feb 2019 22:09:25 -0500 Subject: [PATCH] Fix failure to trim querybuf (and memory tests that fail because of it) --- src/networking.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/networking.cpp b/src/networking.cpp index 36d82a189..cc3d9253e 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -1926,6 +1926,7 @@ int processMultibulkBuffer(client *c) { * pending query buffer, already representing a full command, to process. */ void processInputBuffer(client *c) { AssertCorrectThread(c); + bool fFreed = false; /* Keep processing while there is something in the input buffer */ while(c->qb_pos < sdslen(c->querybuf)) { @@ -1990,13 +1991,16 @@ void processInputBuffer(client *c) { /* freeMemoryIfNeeded may flush slave output buffers. This may * result into a slave, that may be the active client, to be * freed. */ - if (server.current_client == NULL) break; + if (server.current_client == NULL) { + fFreed = true; + break; + } server.current_client = NULL; } } /* Trim to pos */ - if (server.current_client != NULL && c->qb_pos) { + if (!fFreed && c->qb_pos) { sdsrange(c->querybuf,c->qb_pos,-1); c->qb_pos = 0; }