* StrBufPlain(): don't access pointers before we check them
authorWilfried Göesgens <willi@citadel.org>
Thu, 6 May 2010 18:43:10 +0000 (18:43 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 6 May 2010 18:43:10 +0000 (18:43 +0000)
libcitadel/lib/stringbuf.c

index d8ff554d708febafb8e13e6221f2384a8b8b5511..b3c3fefb9697effc0026eaac402da5cbe1407fb4 100644 (file)
@@ -422,7 +422,7 @@ StrBuf* NewStrBufPlain(const char* ptr, int nChars)
  */
 int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars)
 {
-       size_t Siz = Buf->BufSize;
+       size_t Siz;
        size_t CopySize;
 
        if (Buf == NULL)
@@ -431,6 +431,9 @@ int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars)
                FlushStrBuf(Buf);
                return -1;
        }
+
+       Siz = Buf->BufSize;
+
        if (nChars < 0)
                CopySize = strlen(ptr);
        else