aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-05-09 18:06:29 +0200
committerGitHub <noreply@github.com>2017-05-09 18:06:29 +0200
commitd76a95824d905006c0ce8f33a703ceaf63b90f9d (patch)
treefa5a03ecf6bd803d1b7c9431b27d663b3585ce88 /src
parent0e873a30f3072dbacfb700f1e331a8c8396f2e1f (diff)
parent823b35e3414dca0c77697e6e59ec30244b7f4eab (diff)
downloadrneovim-d76a95824d905006c0ce8f33a703ceaf63b90f9d.tar.gz
rneovim-d76a95824d905006c0ce8f33a703ceaf63b90f9d.tar.bz2
rneovim-d76a95824d905006c0ce8f33a703ceaf63b90f9d.zip
Merge #6707 from ZyX-I/fix-strchr-invalid
Diffstat (limited to 'src')
-rw-r--r--src/nvim/strings.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index f19cf7a261..c5fd8741b8 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -428,16 +428,15 @@ int vim_strnicmp(const char *s1, const char *s2, size_t len)
/// strchr() version which handles multibyte strings
///
/// @param[in] string String to search in.
-/// @param[in] c Character to search for. Must be a valid character.
+/// @param[in] c Character to search for.
///
/// @return Pointer to the first byte of the found character in string or NULL
-/// if it was not found. NUL character is never found, use `strlen()`
-/// instead.
+/// if it was not found or character is invalid. NUL character is never
+/// found, use `strlen()` instead.
char_u *vim_strchr(const char_u *const string, const int c)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- assert(c >= 0);
- if (c == 0) {
+ if (c <= 0) {
return NULL;
} else if (c < 0x80) {
return (char_u *)strchr((const char *)string, c);