* serv_read_binary(): in some cases we can get here without having anything in our...
authorWilfried Göesgens <willi@citadel.org>
Tue, 23 Mar 2010 22:34:47 +0000 (22:34 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 23 Mar 2010 22:34:47 +0000 (22:34 +0000)
webcit/tcp_sockets.c

index bf8762fd3f2588608fc342c71bbc49dcde3ee212..60f8b44cf21ee3da49fe448a66d231efb5762797 100644 (file)
@@ -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,