From fe13d12bdad68ae2bd5ba28159016c2809894a7e Mon Sep 17 00:00:00 2001 From: xiaoshitou <770761913@qq.com> Date: Thu, 20 Feb 2020 20:19:10 +0800 Subject: [PATCH 1/3] Update stream.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix function readmembuf bug. for example,if wp=0 and we set i=0, we hope to break this while loop. unfortunately,next execute i++,and for loop will not break. here contain bug. --- src/stream.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stream.c b/src/stream.c index f6f69e4cb..c70e5b049 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2574,7 +2574,10 @@ static int readmembuf(membuf_t *membuf, unsigned char *buff, int n, char *msg) lock(&membuf->lock); for (i=membuf->rp;i!=membuf->wp&&nr=membuf->bufsize) i=0; + if (i>=membuf->bufsize) { + i=0; + if(i==membuf->wp) break; + } buff[nr++]=membuf->buf[i]; } membuf->rp=i; @@ -3351,4 +3354,4 @@ extern void strsendcmd(stream_t *str, const char *cmd) } if (*q=='\0') break; else p=q+1; } -} \ No newline at end of file +} From da69a6b78652f26fe42fb34c2c04a3b43784f3d8 Mon Sep 17 00:00:00 2001 From: xiaoshitou <770761913@qq.com> Date: Thu, 20 Feb 2020 20:25:43 +0800 Subject: [PATCH 2/3] Update stream.c From 7c11d07837259914787fea3067fc4b645da35aa7 Mon Sep 17 00:00:00 2001 From: xiaoshitou <770761913@qq.com> Date: Thu, 20 Feb 2020 20:27:31 +0800 Subject: [PATCH 3/3] Update stream.c delete new end line