* zero-safe StrtoI/L
[citadel.git] / libcitadel / lib / stringbuf.c
index f5cfbbb374866a2d6e45499e0334420db600d4c0..67a50ece57b97c64f1de39dcb550eedc57d5b4ca 100644 (file)
@@ -271,6 +271,8 @@ void HFreeStrBuf (void *VFreeMe)
  */
 long StrTol(const StrBuf *Buf)
 {
+       if (Buf == NULL)
+               return 0;
        if(Buf->BufUsed > 0)
                return atol(Buf->buf);
        else
@@ -282,7 +284,9 @@ long StrTol(const StrBuf *Buf)
  */
 int StrToi(const StrBuf *Buf)
 {
-       if(Buf->BufUsed > 0)
+       if (Buf == NULL)
+               return 0;
+       if (Buf->BufUsed > 0)
                return atoi(Buf->buf);
        else
                return 0;