diff --git a/src/nvim/eval/list.c b/src/nvim/eval/list.c index 6f4f637f7e..2225fba5d6 100644 --- a/src/nvim/eval/list.c +++ b/src/nvim/eval/list.c @@ -465,13 +465,12 @@ static varnumber_T count_string(const char *haystack, const char *needle, bool i return 0; } + size_t needlelen = strlen(needle); if (ic) { - const size_t len = strlen(needle); - while (*p != NUL) { - if (mb_strnicmp(p, needle, len) == 0) { + if (mb_strnicmp(p, needle, needlelen) == 0) { n++; - p += len; + p += needlelen; } else { MB_PTR_ADV(p); } @@ -480,7 +479,7 @@ static varnumber_T count_string(const char *haystack, const char *needle, bool i const char *next; while ((next = strstr(p, needle)) != NULL) { n++; - p = next + strlen(needle); + p = next + needlelen; } } diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 24642374ef..5982597b4b 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -804,7 +804,7 @@ size_t vim_snprintf_safelen(char *str, size_t str_m, const char *fmt, ...) int str_l; va_start(ap, fmt); - str_l = vim_vsnprintf(str, str_m, fmt, ap); + str_l = vim_vsnprintf_typval(str, str_m, fmt, ap, NULL); va_end(ap); if (str_l < 0) {