- if (bytes < bufremain)
- bufremain = bytes;
- StrBufAppendBufPlain(Target, Hdr->Pos, bufremain, 0);
- StrBufCutLeft(Hdr->ReadBuf, bufremain);
+ if (StrLength(Hdr->ReadBuf) > 0)
+ {
+ bufremain = StrLength(Hdr->ReadBuf) - (Hdr->Pos - ChrPtr(Hdr->ReadBuf));
+
+ if (bytes < bufremain)
+ bufremain = bytes;
+ StrBufAppendBufPlain(Target, Hdr->Pos, bufremain, 0);
+ StrBufCutLeft(Hdr->ReadBuf, bufremain);
+ }