* fix another buggy buffer increase
authorWilfried Göesgens <willi@citadel.org>
Sun, 7 Jun 2009 19:53:02 +0000 (19:53 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 7 Jun 2009 19:53:02 +0000 (19:53 +0000)
libcitadel/lib/stringbuf.c

index 4bec25f3dde47740c3e4d931ee054b3c6c4331a3..3a517aa05c42d91e0194423ea500b3ca4f752910 100644 (file)
@@ -1104,9 +1104,11 @@ int StrBufExtract_token(StrBuf *dest, const StrBuf *Source, int parmnum, char se
                if (*s == separator) {
                        ++current_token;
                }
-               if (len >= dest->BufSize)
+               if (len >= dest->BufSize) {
+                       dest->BufUsed = len;
                        if (!IncreaseBuf(dest, 1, -1))
                                break;
+               }
                if ( (current_token == parmnum) && 
                     (*s != separator)) {
                        dest->buf[len] = *s;
@@ -1255,11 +1257,13 @@ int StrBufExtract_NextToken(StrBuf *dest, const StrBuf *Source, const char **pSt
                if (*s == separator) {
                        ++current_token;
                }
-               if (len >= dest->BufSize)
+               if (len >= dest->BufSize) {
+                       dest->BufUsed = len;
                        if (!IncreaseBuf(dest, 1, -1)) {
                                *pStart = EndBuffer + 1;
                                break;
                        }
+               }
                if ( (current_token == 0) && 
                     (*s != separator)) {
                        dest->buf[len] = *s;