mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 10:18:18 +00:00
Merge pull request #6397 from jamessan/coverity
Fix latest Coverity issues
This commit is contained in:
@@ -64,7 +64,7 @@ void *je_realloc(void *ptr, size_t size)
|
|||||||
// of the memory allocated for item.
|
// of the memory allocated for item.
|
||||||
typedef struct {} dictitem_T;
|
typedef struct {} dictitem_T;
|
||||||
typedef struct {} dict_T;
|
typedef struct {} dict_T;
|
||||||
int dict_add(dict_T *d, dictitem_T *item)
|
int tv_dict_add(dict_T *const d, dictitem_T *const item)
|
||||||
{
|
{
|
||||||
__coverity_escape__(item);
|
__coverity_escape__(item);
|
||||||
}
|
}
|
||||||
|
@@ -11008,18 +11008,19 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog)
|
|||||||
cmdline_row = msg_row;
|
cmdline_row = msg_row;
|
||||||
|
|
||||||
const char *defstr = "";
|
const char *defstr = "";
|
||||||
|
char buf[NUMBUFLEN];
|
||||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||||
char buf[NUMBUFLEN];
|
|
||||||
defstr = tv_get_string_buf_chk(&argvars[1], buf);
|
defstr = tv_get_string_buf_chk(&argvars[1], buf);
|
||||||
if (defstr != NULL) {
|
if (defstr != NULL) {
|
||||||
stuffReadbuffSpec(defstr);
|
stuffReadbuffSpec(defstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN) {
|
if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN) {
|
||||||
|
char buf2[NUMBUFLEN];
|
||||||
// input() with a third argument: completion
|
// input() with a third argument: completion
|
||||||
rettv->vval.v_string = NULL;
|
rettv->vval.v_string = NULL;
|
||||||
|
|
||||||
const char *const xp_name = tv_get_string_buf_chk(&argvars[2], buf);
|
const char *const xp_name = tv_get_string_buf_chk(&argvars[2], buf2);
|
||||||
if (xp_name == NULL) {
|
if (xp_name == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -4670,6 +4670,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg'
|
char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg'
|
||||||
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
|
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
|
||||||
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
|
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
|
||||||
|
bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
|
||||||
size_t buf_size = n * 2 + 30 + STRLEN(kp);
|
size_t buf_size = n * 2 + 30 + STRLEN(kp);
|
||||||
char *buf = xmalloc(buf_size);
|
char *buf = xmalloc(buf_size);
|
||||||
buf[0] = NUL;
|
buf[0] = NUL;
|
||||||
@@ -4692,7 +4693,9 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'K':
|
case 'K':
|
||||||
if (kp_ex) {
|
if (kp_help) {
|
||||||
|
STRCPY(buf, "he! ");
|
||||||
|
} else if (kp_ex) {
|
||||||
if (cap->count0 != 0) { // Send the count to the ex command.
|
if (cap->count0 != 0) { // Send the count to the ex command.
|
||||||
snprintf(buf, buf_size, "%" PRId64, (int64_t)(cap->count0));
|
snprintf(buf, buf_size, "%" PRId64, (int64_t)(cap->count0));
|
||||||
}
|
}
|
||||||
@@ -4755,7 +4758,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now grab the chars in the identifier
|
// Now grab the chars in the identifier
|
||||||
if (cmdchar == 'K') {
|
if (cmdchar == 'K' && !kp_help) {
|
||||||
ptr = vim_strnsave(ptr, n);
|
ptr = vim_strnsave(ptr, n);
|
||||||
if (kp_ex) {
|
if (kp_ex) {
|
||||||
// Escape the argument properly for an Ex command
|
// Escape the argument properly for an Ex command
|
||||||
|
@@ -1054,13 +1054,15 @@ void set_init_3(void)
|
|||||||
*/
|
*/
|
||||||
void set_helplang_default(const char *lang)
|
void set_helplang_default(const char *lang)
|
||||||
{
|
{
|
||||||
int idx;
|
if (lang == NULL) {
|
||||||
|
|
||||||
const size_t lang_len = strlen(lang);
|
|
||||||
if (lang == NULL || lang_len < 2) { // safety check
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
idx = findoption("hlg");
|
|
||||||
|
const size_t lang_len = strlen(lang);
|
||||||
|
if (lang_len < 2) { // safety check
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int idx = findoption("hlg");
|
||||||
if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
|
if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
|
||||||
if (options[idx].flags & P_ALLOCED)
|
if (options[idx].flags & P_ALLOCED)
|
||||||
free_string_option(p_hlg);
|
free_string_option(p_hlg);
|
||||||
|
@@ -615,9 +615,9 @@ char *vim_getenv(const char *name)
|
|||||||
vim_path = (char *)p_hf;
|
vim_path = (char *)p_hf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char exe_name[MAXPATHL];
|
||||||
// Find runtime path relative to the nvim binary: ../share/nvim/runtime
|
// Find runtime path relative to the nvim binary: ../share/nvim/runtime
|
||||||
if (vim_path == NULL) {
|
if (vim_path == NULL) {
|
||||||
char exe_name[MAXPATHL];
|
|
||||||
size_t exe_name_len = MAXPATHL;
|
size_t exe_name_len = MAXPATHL;
|
||||||
if (os_exepath(exe_name, &exe_name_len) == 0) {
|
if (os_exepath(exe_name, &exe_name_len) == 0) {
|
||||||
char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
|
char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
|
||||||
|
Reference in New Issue
Block a user