X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Ftcp_sockets.c;h=60f8b44cf21ee3da49fe448a66d231efb5762797;hp=bf8762fd3f2588608fc342c71bbc49dcde3ee212;hb=491efe6ea9a1035b0f6d2e9be5ada94b37d50ce9;hpb=c2f44e5fd280c1f926cab1d44ccdd01b64d5375e 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,