From 491efe6ea9a1035b0f6d2e9be5ada94b37d50ce9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 23 Mar 2010 22:34:47 +0000 Subject: [PATCH] * serv_read_binary(): in some cases we can get here without having anything in our read buffer; catch this situation. --- webcit/tcp_sockets.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) 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, -- 2.30.2