As per dothebart's advice, revise StrBufIsNumber to check for NULL buffer, no longer...
authorMatt <matt@uncensored.citadel.org>
Sun, 14 Dec 2008 12:25:54 +0000 (12:25 +0000)
committerMatt <matt@uncensored.citadel.org>
Sun, 14 Dec 2008 12:25:54 +0000 (12:25 +0000)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index bdb40d34a44b35711a797a34c540cea4be758033..9a5ec9a0f99004e4fe5b22466c1b4f5327384031 100644 (file)
@@ -285,6 +285,7 @@ void StrMsgEscAppend(StrBuf *Target, StrBuf *Source, const char *PlainIn);
 
 long StrTol(const StrBuf *Buf);
 int StrToi(const StrBuf *Buf);
+int StrBufIsNumber(const StrBuf *Buf);
 long StrBuf_Utf8StrLen(StrBuf *Buf);
 long StrBuf_Utf8StrCut(StrBuf *Buf, int maxlen);
 
index db6a3b12b7a5c5cb90009813a48715afb7611ada..8fe5ab0529ab2788556f32bb90e5d5ac7deceb7e 100644 (file)
@@ -32,7 +32,7 @@ int ZEXPORT compress_gzip(Bytef * dest, size_t * destLen,
 struct StrBuf {
        char *buf;         /**< the pointer to the dynamic buffer */
        long BufSize;      /**< how many spcae do we optain */
-       long BufUsed;      /**< Number of Chars used excluding the trailing \0 */
+       long BufUsed;      /**< StNumber of Chars used excluding the trailing \0 */
        int ConstBuf;      /**< are we just a wrapper arround a static buffer and musn't we be changed? */
 };
 
@@ -295,9 +295,15 @@ int StrToi(const StrBuf *Buf)
  * \brief Checks to see if the string is a pure number 
  */
 int StrBufIsNumber(const StrBuf *Buf) {
+  if (Buf == NULL) {
+       return 0;
+  }
   char * pEnd;
   strtoll(Buf->buf, &pEnd, 10);
-  return (strlen(pEnd) > 0) ? 0 : 1;
+  if (pEnd != NULL && ((Buf->buf)-pEnd) == 0) {
+    return 0;
+  }
+  return 1;
 } 
 /**
  * \brief modifies a Single char of the Buf