diff options
Diffstat (limited to 'pjlib/include/pj/string_i.h')
-rw-r--r-- | pjlib/include/pj/string_i.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pjlib/include/pj/string_i.h b/pjlib/include/pj/string_i.h index 53794864..b26d5ead 100644 --- a/pjlib/include/pj/string_i.h +++ b/pjlib/include/pj/string_i.h @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <pj/assert.h> #include <pj/pool.h> PJ_IDEF(pj_str_t) pj_str(char *str) @@ -117,6 +118,7 @@ PJ_IDEF(pj_str_t*) pj_strcpy2(pj_str_t *dst, const char *src) PJ_IDEF(pj_str_t*) pj_strncpy( pj_str_t *dst, const pj_str_t *src, pj_ssize_t max) { + pj_assert(max >= 0); if (max > src->slen) max = src->slen; pj_memcpy(dst->ptr, src->ptr, max); dst->slen = max; @@ -126,6 +128,8 @@ PJ_IDEF(pj_str_t*) pj_strncpy( pj_str_t *dst, const pj_str_t *src, PJ_IDEF(pj_str_t*) pj_strncpy_with_null( pj_str_t *dst, const pj_str_t *src, pj_ssize_t max) { + pj_assert(max > 0); + if (max <= src->slen) max = max-1; else |