0
0
mirror of https://github.com/vim/vim.git synced 2025-08-23 19:34:27 -04:00

patch 9.1.1661: Coverity finds a few issues in clientserver.c

Problem:  Coverity finds a few issues in clientserver.c
          (also by Tony Mechelynck)
Solution: Fix issues and warnings (Foxe Chen)

closes: #18057

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen 2025-08-20 22:00:41 +02:00 committed by Christian Brabandt
parent 38315295ef
commit c0a3eda6ba
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 29 additions and 11 deletions

View File

@ -330,7 +330,7 @@ cmdsrv_main(
char_u *res;
int i;
char_u *sname;
int ret;
int ret = -1;
int didone = FALSE;
int exiterr = 0;
char **newArgV = argv + 1;
@ -904,19 +904,19 @@ remote_common(typval_T *argvars, typval_T *rettv, int expr)
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
if (socket_server_send(server_name, keys, &r, &client, expr,
timeout * 1000, TRUE) < 0)
goto stuff;
goto fail;
#endif
#ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, timeout,
0, TRUE) < 0)
goto stuff;
goto fail;
#endif
# endif
#if !defined(MSWIN)
if (FALSE)
{
stuff:
fail:
#else
{
#endif
@ -949,6 +949,7 @@ stuff:
idvar = tv_get_string_chk(&argvars[2]);
if (idvar != NULL && *idvar != NUL)
{
str[0] = NUL;
#ifdef MSWIN
sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
#else

View File

@ -9326,6 +9326,7 @@ socket_server_init(char_u *name)
vim_free(path);
return OK;
fail:
close(fd);
vim_free(path);
socket_server_uninit();
return FAIL;
@ -9844,7 +9845,10 @@ socket_server_connect(char_u *name, char_u **path, int silent)
socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (socket_fd == -1)
goto fail;
{
vim_free(socket_path);
return -1;
}
addr.sun_family = AF_UNIX;
vim_snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path);
@ -9856,7 +9860,9 @@ socket_server_connect(char_u *name, char_u **path, int silent)
if (!silent)
semsg(_(e_socket_server_failed_connecting), socket_path,
strerror(errno));
goto fail;
close(socket_fd);
vim_free(socket_path);
return -1;
}
if (path != NULL)
@ -9865,10 +9871,6 @@ socket_server_connect(char_u *name, char_u **path, int silent)
vim_free(socket_path);
return socket_fd;
fail:
close(socket_fd);
vim_free(socket_path);
return -1;
}
@ -10337,7 +10339,7 @@ socket_server_exec_cmd(ss_cmd_T *cmd, int fd)
cmd->cmd_type == SS_CMD_TYPE_KEYSTROKES)
{
// Either an expression or keystrokes.
if (socket_server_valid() && enc != NULL)
if (socket_server_valid() && enc != NULL && str != NULL)
{
str = serverConvert(enc, str, &to_free);

View File

@ -15,6 +15,19 @@ func Verify_remote_feature_works()
enew
let buf = RunVimInTerminal('--servername XVIMTEST', {'rows': 8})
call TermWait(buf)
" For some reason when the socket server is being used, the terminal Vim never
" receives the `:w! XVimRemoteTest.txt` command from term_sendkeys.
if has('socketserver') && !has('X11')
if match(serverlist(), "XVIMTEST") == -1
call StopVimInTerminal(buf)
throw s:skip
endif
let s:remote = 1
return
endif
let cmd = GetVimCommandCleanTerm() .. '--serverlist'
call term_sendkeys(buf, ":r! " .. cmd .. "\<CR>")
call TermWait(buf)

View File

@ -724,6 +724,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1661,
/**/
1660,
/**/