diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-07-23 13:26:33 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-07-23 13:26:33 +0000 |
commit | 8628d5dae139665836ac471628339feab93c83f1 (patch) | |
tree | 31dc0a397f29c91c9799f4ff092002c10b6c970e | |
parent | afc016bde15daa7769e561d30c027f6c13b51bac (diff) |
pj_strtoul() should stop the conversion as soon as it finds a non-digit character in the input
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2169 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjlib/include/pj/string.h | 4 | ||||
-rw-r--r-- | pjlib/src/pj/string.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/pjlib/include/pj/string.h b/pjlib/include/pj/string.h index 1866e64a..a56861d0 100644 --- a/pjlib/include/pj/string.h +++ b/pjlib/include/pj/string.h @@ -535,7 +535,9 @@ PJ_IDECL(pj_str_t*) pj_strtrim( pj_str_t *str ); PJ_DECL(char*) pj_create_random_string(char *str, pj_size_t length); /** - * Convert string to unsigned integer. + * Convert string to unsigned integer. The conversion will stop as + * soon as non-digit character is found or all the characters have + * been processed. * * @param str the string. * diff --git a/pjlib/src/pj/string.c b/pjlib/src/pj/string.c index 8300cd55..9e0918ef 100644 --- a/pjlib/src/pj/string.c +++ b/pjlib/src/pj/string.c @@ -117,6 +117,8 @@ PJ_DEF(unsigned long) pj_strtoul(const pj_str_t *str) value = 0; for (i=0; i<(unsigned)str->slen; ++i) { + if (!pj_isdigit(str->ptr[i])) + break; value = value * 10 + (str->ptr[i] - '0'); } return value; |