diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-07 14:50:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-07 14:50:44 +0200 |
commit | c4f833808af930505017c9389d44a828601e247c (patch) | |
tree | 577f9425a910a666e2d6d8cad51a411460ec8cca /src/if_python3.c | |
parent | 8858498516108432453526f07783f14c9196e112 (diff) | |
download | vim-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_python3.c')
-rw-r--r-- | src/if_python3.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/if_python3.c b/src/if_python3.c index d68ab85a8..6949b02ef 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -733,8 +733,8 @@ get_py3_exceptions(void) #endif /* DYNAMIC_PYTHON3 */ static int py3initialised = 0; - #define PYINITIALISED py3initialised +static int python_end_called = FALSE; #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self) @@ -817,6 +817,7 @@ python3_end(void) if (recurse != 0) return; + python_end_called = TRUE; ++recurse; #ifdef DYNAMIC_PYTHON3 @@ -938,6 +939,9 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) PyObject *cmdbytes; PyGILState_STATE pygilstate; + if (python_end_called) + goto theend; + #if defined(MACOS) && !defined(MACOS_X_UNIX) GetPort(&oldPort); /* Check if the Python library is available */ |