From b5a6a667166db4fe41926618d83816ffb33991e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 1 Feb 2010 19:22:33 +0000 Subject: [PATCH] * don't free the buffer in here, its _not_ ours. * abort if the server has gone away --- webcit/serv_func.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/webcit/serv_func.c b/webcit/serv_func.c index abb95fa0a..3a6487172 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -540,20 +540,20 @@ void server_to_text() */ int read_server_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) { - char buf[SIZ]; + wcsession *WCC = WC; size_t bytes = 0; size_t thisblock = 0; if (Ret == NULL) return -1; - while (bytes < total_len) { + while ((WCC->serv_sock!=-1) && + (bytes < total_len)) { thisblock = 4095; if ((total_len - bytes) < thisblock) { thisblock = total_len - bytes; if (thisblock == 0) { FlushStrBuf(Ret); - FreeStrBuf(&Buf); return -1; } } @@ -564,17 +564,15 @@ int read_server_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) { StrBufCutLeft(Buf, 4); thisblock = StrTol(Buf); - if (!WC->connected) { + if (WCC->serv_sock==-1) { FlushStrBuf(Ret); - FreeStrBuf(&Buf); return -1; } StrBuf_ServGetBLOBBuffered(Ret, thisblock); bytes += thisblock; } else { - FreeStrBuf(&Buf); - lprintf(3, "Error: %s\n", &buf[4]); + lprintf(3, "Error: %s\n", ChrPtr(Buf) + 4); return -1; } } -- 2.30.2