]> code.citadel.org Git - citadel.git/blobdiff - libcitadel/lib/stringbuf.c
* StrBufExtract_token wouldn't reset its target buffer in all conditions.
[citadel.git] / libcitadel / lib / stringbuf.c
index 67a50ece57b97c64f1de39dcb550eedc57d5b4ca..03632033602ac168d5885644b067159671735ca2 100644 (file)
@@ -807,20 +807,22 @@ int StrBufExtract_token(StrBuf *dest, const StrBuf *Source, int parmnum, char se
        const char *s, *e;              //* source * /
        int len = 0;                    //* running total length of extracted string * /
        int current_token = 0;          //* token currently being processed * /
+        
+       if (dest != NULL) {
+               dest->buf[0] = '\0';
+               dest->BufUsed = 0;
+       }
+       else
+               return(-1);
 
        if ((Source == NULL) || (Source->BufUsed ==0)) {
                return(-1);
        }
        s = Source->buf;
        e = s + Source->BufUsed;
-       if (dest == NULL) {
-               return(-1);
-       }
 
        //cit_backtrace();
        //lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
-       dest->buf[0] = '\0';
-       dest->BufUsed = 0;
 
        while ((s<e) && !IsEmptyStr(s)) {
                if (*s == separator) {