Mercurial > vim
comparison src/eval.c @ 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 | 1f81c571d0e7 |
children | fa2668601c7a |
comparison
equal
deleted
inserted
replaced
8185:c3a233d90eca | 8186:5fed86dac210 |
---|---|
15037 { | 15037 { |
15038 typval_T argv[3]; | 15038 typval_T argv[3]; |
15039 typval_T rettv; | 15039 typval_T rettv; |
15040 int dummy; | 15040 int dummy; |
15041 | 15041 |
15042 /* invoke the exit callback */ | 15042 /* invoke the exit callback; make sure the refcount is > 0 */ |
15043 ++job->jv_refcount; | |
15043 argv[0].v_type = VAR_JOB; | 15044 argv[0].v_type = VAR_JOB; |
15044 argv[0].vval.v_job = job; | 15045 argv[0].vval.v_job = job; |
15045 argv[1].v_type = VAR_NUMBER; | 15046 argv[1].v_type = VAR_NUMBER; |
15046 argv[1].vval.v_number = job->jv_exitval; | 15047 argv[1].vval.v_number = job->jv_exitval; |
15047 call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb), | 15048 call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb), |
15048 &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL); | 15049 &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL); |
15049 clear_tv(&rettv); | 15050 clear_tv(&rettv); |
15051 --job->jv_refcount; | |
15050 } | 15052 } |
15051 if (job->jv_status == JOB_ENDED && job->jv_refcount == 0) | 15053 if (job->jv_status == JOB_ENDED && job->jv_refcount == 0) |
15052 { | 15054 { |
15053 /* The job already was unreferenced, now that it ended it can be | 15055 /* The job was already unreferenced, now that it ended it can be |
15054 * freed. Careful: caller must not use "job" after this! */ | 15056 * freed. Careful: caller must not use "job" after this! */ |
15055 job_free(job); | 15057 job_free(job); |
15056 } | 15058 } |
15057 } | 15059 } |
15058 return result; | 15060 return result; |