* generaly NULL *Pos before re-caclulating it
[citadel.git] / libcitadel / lib / stringbuf.c
index afaa2e6e539edc0cc9cbb5abcd75b4ca76086ffb..a1955fad24d70903a9c20959d2b8af754d71515c 100644 (file)
@@ -3265,14 +3265,15 @@ int StrBufTCP_read_buffered_line_fast(StrBuf *Line,
                        {
                                long apos;
 
-                               apos = pLF - IOBuf->buf;
+                               if (pLF != NULL) apos = pLF - IOBuf->buf;
                                IncreaseBuf(IOBuf, 1, -1);      
-                               pLF = IOBuf->buf + apos;
+                               if (pLF != NULL) pLF = IOBuf->buf + apos;
                        }
 
                        continue;
                }
        }
+       *Pos = NULL;
        if (pLF != NULL) {
                pos = IOBuf->buf;
                rlen = 0;
@@ -3283,7 +3284,6 @@ int StrBufTCP_read_buffered_line_fast(StrBuf *Line,
                if (pLF + 1 >= IOBuf->buf + IOBuf->BufUsed)
                {
                        FlushStrBuf(IOBuf);
-                       *Pos = NULL;
                }
                else 
                        *Pos = pLF + 1;