patch 8.0.0698: crash on exit when using Python function in timer.
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)
diff --git a/src/if_python.c b/src/if_python.c
index 6b2ce56..a280459 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -779,6 +779,7 @@
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 @@
if (recurse != 0)
return;
+ python_end_called = TRUE;
++recurse;
#ifdef DYNAMIC_PYTHON
@@ -1040,6 +1042,8 @@
}
++recursive;
#endif
+ if (python_end_called)
+ return;
#if defined(MACOS) && !defined(MACOS_X_UNIX)
GetPort(&oldPort);
@@ -1568,7 +1572,7 @@
(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;