From 89a84baaf92536e4d463f472a2530e95ae60c7a5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 26 Oct 2015 14:49:03 +0300 Subject: option: Fix typos that may lead to SEGV in some cases --- src/nvim/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index a4cfe45f10..de0c8e87f5 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -333,7 +333,7 @@ static inline size_t compute_double_colon_len(const char *const val, const size_t single_suf_len) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE { - if (val == NULL && *val) { + if (val == NULL || *val == NUL) { return 0; } size_t ret = 0; @@ -378,7 +378,7 @@ static inline char *add_colon_dirs(char *dest, const char *const val, const bool forward) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) { - if (val == NULL && *val) { + if (val == NULL || *val == NUL) { return dest; } const void *iter = NULL; -- cgit From be6b784766655d38ea28fb382d3af6789e4e4a89 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 26 Oct 2015 14:51:56 +0300 Subject: option: Fix strange condition in add_dir function --- src/nvim/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index de0c8e87f5..f30d10d0bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -435,7 +435,7 @@ static inline char *add_dir(char *dest, const char *const dir, const char *const suf2, const size_t len2) FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT { - if (dir == NULL && dir_len != 0) { + if (dir == NULL || dir_len == 0) { return dest; } dest = strcpy_comma_escaped(dest, dir, dir_len); -- cgit