mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 21:55:17 -07:00
eval: Fix coverity false positive.
** CID 74786: Resource leak (RESOURCE_LEAK) /src/nvim/eval.c: 10614 in f_jobsend() /src/nvim/eval.c: 10616 in f_jobsend() save_tv_as_string() should return NULL and input_len <= 0 for an empty string or error. Callers should check that input != NULL instead of input_len > 0 and assert(input == NULL) when the length must be checked.
This commit is contained in:
parent
98b11f5db3
commit
927c6a148d
@ -10631,10 +10631,10 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
ssize_t input_len;
|
||||
char *input = (char *) save_tv_as_string(&argvars[1], &input_len, true);
|
||||
if (input_len < 0) {
|
||||
return; // Error handled by save_tv_as_string().
|
||||
} else if (input_len == 0) {
|
||||
return; // Not an error, but nothing to do.
|
||||
if (!input) {
|
||||
// Either the error has been handled by save_tv_as_string(), or there is no
|
||||
// input to send.
|
||||
return;
|
||||
}
|
||||
|
||||
WBuffer *buf = wstream_new_buffer(input, input_len, 1, free);
|
||||
@ -14559,7 +14559,8 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
|
||||
// get input to the shell command (if any), and its length
|
||||
ssize_t input_len;
|
||||
char *input = (char *) save_tv_as_string(&argvars[1], &input_len, false);
|
||||
if (input_len == -1) {
|
||||
if (input_len < 0) {
|
||||
assert(input == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user