summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjlib/include/pj/string.h4
-rw-r--r--pjlib/src/pj/string.c2
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;