diff --git a/src/chars.c b/src/chars.c index f54441b65c1af25508cc658e4d21d17e22413641..1eb11775655bb46aa8e6ce3f859e82266c140dbc 100644 --- a/src/chars.c +++ b/src/chars.c @@ -268,6 +268,8 @@ int mb_cur_max(void) * length. */ char *make_mbchar(unsigned int chr, char *chr_mb, int *chr_mb_len) { + assert(chr_mb != NULL && chr_mb_len != NULL); + #ifdef NANO_WIDE if (!ISSET(NO_UTF8)) { *chr_mb_len = wctomb(chr_mb, chr); @@ -441,8 +443,6 @@ int nstrcasecmp(const char *s1, const char *s2) /* This function is equivalent to strcasecmp() for multibyte strings. */ int mbstrcasecmp(const char *s1, const char *s2) { - assert(s1 != NULL && s2 != NULL); - #ifdef NANO_WIDE if (!ISSET(NO_UTF8)) { char *s1_mb = charalloc(mb_cur_max()); @@ -450,6 +450,8 @@ int mbstrcasecmp(const char *s1, const char *s2) int s1_mb_len, s2_mb_len; wchar_t ws1, ws2; + assert(s1 != NULL && s2 != NULL); + while (*s1 != '\0' && *s2 != '\0') { s1_mb_len = parse_mbchar(s1, s1_mb #ifdef NANO_WIDE @@ -518,8 +520,6 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n) * strings. */ int mbstrncasecmp(const char *s1, const char *s2, size_t n) { - assert(s1 != NULL && s2 != NULL); - #ifdef NANO_WIDE if (!ISSET(NO_UTF8)) { char *s1_mb = charalloc(mb_cur_max()); @@ -527,6 +527,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n) int s1_mb_len, s2_mb_len; wchar_t ws1, ws2; + assert(s1 != NULL && s2 != NULL); + while (n > 0 && *s1 != '\0' && *s2 != '\0') { s1_mb_len = parse_mbchar(s1, s1_mb #ifdef NANO_WIDE