aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Prager <splinterofchaos@gmail.com>2014-11-27 15:09:03 -0500
committerScott Prager <splinterofchaos@gmail.com>2014-11-27 15:12:35 -0500
commit927c6a148d3721bb04ccbe54346b08ec00528e60 (patch)
tree3477189c3155cc3b4f3f81cf7be783e4fb36d516 /src
parent98b11f5db3a99ef633ad77ddc6b22dc428873e95 (diff)
downloadrneovim-927c6a148d3721bb04ccbe54346b08ec00528e60.tar.gz
rneovim-927c6a148d3721bb04ccbe54346b08ec00528e60.tar.bz2
rneovim-927c6a148d3721bb04ccbe54346b08ec00528e60.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 34990a62e0..8be25bc34e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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;
}