From: Wilfried Göesgens Date: Tue, 23 Mar 2010 22:34:47 +0000 (+0000) Subject: * serv_read_binary(): in some cases we can get here without having anything in our... X-Git-Tag: v7.86~289 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=491efe6ea9a1035b0f6d2e9be5ada94b37d50ce9 * serv_read_binary(): in some cases we can get here without having anything in our read buffer; catch this situation. --- diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index bf8762fd3..60f8b44cf 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -394,23 +394,25 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) return -1; } - pch = ChrPtr(WCC->ReadBuf); - YetRead = WCC->ReadPos - pch; - if (YetRead > 0) - { - long StillThere; - - StillThere = StrLength(WCC->ReadBuf) - - YetRead; - - StrBufPlain(Ret, - WCC->ReadPos, - StillThere); - total_len -= StillThere; - } - FlushStrBuf(WCC->ReadBuf); - WCC->ReadPos = NULL; - + if (WCC->ReadPos != NULL) { + pch = ChrPtr(WCC->ReadBuf); + + YetRead = WCC->ReadPos - pch; + if (YetRead > 0) + { + long StillThere; + + StillThere = StrLength(WCC->ReadBuf) - + YetRead; + + StrBufPlain(Ret, + WCC->ReadPos, + StillThere); + total_len -= StillThere; + } + FlushStrBuf(WCC->ReadBuf); + WCC->ReadPos = NULL; + } if (total_len > 0) { rc = StrBufReadBLOB(Ret,