From 70cb863096a0a25d6d51f53807f3991fa21aa93f Mon Sep 17 00:00:00 2001 From: oni-link Date: Fri, 7 Nov 2014 19:13:47 +0100 Subject: job: Fix memory leak in job_start(). If a new job cannot be started because no slots are free, we return early without freeing the argv argument. --- src/nvim/os/job.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index 7ae2a86fc2..551a7d1c87 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -139,6 +139,7 @@ Job *job_start(char **argv, if (i == MAX_RUNNING_JOBS) { // No free slots + shell_free_argv(argv); *status = 0; return NULL; } -- cgit From cf95d27689ac48c48c6ff2f360439beeac3976af Mon Sep 17 00:00:00 2001 From: oni-link Date: Sat, 8 Nov 2014 03:28:06 +0100 Subject: Mark some function arguments as [consumed] in the docs. The argument argv of job_start() and channel_from_job() will be freed. Mark them as such in the comments of this functions. --- src/nvim/msgpack_rpc/channel.c | 2 +- src/nvim/os/job.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index aa6008558f..da1dc8d1b5 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -119,7 +119,7 @@ void channel_teardown(void) /// Creates an API channel by starting a job and connecting to its /// stdin/stdout. stderr is forwarded to the editor error stream. /// -/// @param argv The argument vector for the process +/// @param argv The argument vector for the process. [consumed] /// @return The channel id uint64_t channel_from_job(char **argv) { diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index 551a7d1c87..17872ab9c9 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -105,7 +105,8 @@ void job_teardown(void) /// Tries to start a new job. /// /// @param argv Argument vector for the process. The first item is the -/// executable to run. +/// executable to run. +/// [consumed] /// @param data Caller data that will be associated with the job /// @param writable If true the job stdin will be available for writing with /// job_write, otherwise it will be redirected to /dev/null -- cgit From dba8433723f1cb5dbfc7e09fde73219aba646f60 Mon Sep 17 00:00:00 2001 From: oni-link Date: Sat, 8 Nov 2014 04:03:04 +0100 Subject: Try to fix problem found in the Travis Ci build. An uv_pipe_t handle for a WStream could be left open for a particular code path. Patch by tarruda. --- src/nvim/os/wstream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index a1f3612418..6a650ce775 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -230,7 +230,11 @@ static void write_cb(uv_write_t *req, int status) if (data->wstream->freed && data->wstream->pending_reqs == 0) { // Last pending write, free the wstream; - free(data->wstream); + if (data->wstream->free_handle) { + uv_close((uv_handle_t *)data->wstream->stream, close_cb); + } else { + free(data->wstream); + } } kmp_free(WRequestPool, wrequest_pool, data); -- cgit