changeset 8186:5fed86dac210 v7.4.1386

commit https://github.com/vim/vim/commit/23c463a157b4f5585ad85efc9f453ffc09c245c3 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 22 11:39:27 2016 +0100 patch 7.4.1386 Problem: When the Job exit callback is invoked, the job may be freed too soon. (Yasuhiro Matsumoto) Solution: Increase refcount.
author Christian Brabandt <cb@256bit.org>
date Mon, 22 Feb 2016 11:45:05 +0100
parents c3a233d90eca
children b1f66b40a945
files src/eval.c src/version.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -15039,7 +15039,8 @@ job_status(job_T *job)
 	    typval_T	rettv;
 	    int		dummy;
 
-	    /* invoke the exit callback */
+	    /* invoke the exit callback; make sure the refcount is > 0 */
+	    ++job->jv_refcount;
 	    argv[0].v_type = VAR_JOB;
 	    argv[0].vval.v_job = job;
 	    argv[1].v_type = VAR_NUMBER;
@@ -15047,10 +15048,11 @@ job_status(job_T *job)
 	    call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb),
 				 &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL);
 	    clear_tv(&rettv);
+	    --job->jv_refcount;
 	}
 	if (job->jv_status == JOB_ENDED && job->jv_refcount == 0)
 	{
-	    /* The job already was unreferenced, now that it ended it can be
+	    /* The job was already unreferenced, now that it ended it can be
 	     * freed. Careful: caller must not use "job" after this! */
 	    job_free(job);
 	}
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1386,
+/**/
     1385,
 /**/
     1384,