summaryrefslogtreecommitdiff
path: root/src/if_python.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-07 14:50:44 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-07 14:50:44 +0200
commitc4f833808af930505017c9389d44a828601e247c (patch)
tree577f9425a910a666e2d6d8cad51a411460ec8cca /src/if_python.c
parent8858498516108432453526f07783f14c9196e112 (diff)
downloadvim-git-c4f833808af930505017c9389d44a828601e247c.tar.gz
patch 8.0.0698: crash on exit when using Python function in timer.v8.0.0698
Problem: When a timer uses ":pyeval" or another Python command and it happens to be triggered while exiting a Crash may happen. (Ricky Zhou) Solution: Avoid running a Python command after python_end() was called. Do not trigger timers while exiting. (closes #1824)
Diffstat (limited to 'src/if_python.c')
-rw-r--r--src/if_python.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/if_python.c b/src/if_python.c
index 6b2ce56ef..a280459db 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -779,6 +779,7 @@ get_exceptions(void)
static int initialised = 0;
#define PYINITIALISED initialised
+static int python_end_called = FALSE;
#define DESTRUCTOR_FINISH(self) self->ob_type->tp_free((PyObject*)self);
@@ -878,6 +879,7 @@ python_end(void)
if (recurse != 0)
return;
+ python_end_called = TRUE;
++recurse;
#ifdef DYNAMIC_PYTHON
@@ -1040,6 +1042,8 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
}
++recursive;
#endif
+ if (python_end_called)
+ return;
#if defined(MACOS) && !defined(MACOS_X_UNIX)
GetPort(&oldPort);
@@ -1568,7 +1572,7 @@ do_pyeval (char_u *str, typval_T *rettv)
(rangeinitializer) init_range_eval,
(runner) run_eval,
(void *) rettv);
- switch(rettv->v_type)
+ switch (rettv->v_type)
{
case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;