From f62994f6ea59ba9ba41dfaefaabf62fe42e53d8b Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Fri, 2 Jul 2021 09:42:31 +0200 Subject: [PATCH] - Fix #506: Python Module Seems to Leak Memory if it Experiences an Unhandled Exception. --- doc/Changelog | 4 ++++ pythonmod/pythonmod.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/doc/Changelog b/doc/Changelog index f4b1295b2..221b6c69b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +2 July 2021: Wouter + - Fix #506: Python Module Seems to Leak Memory if it Experiences an + Unhandled Exception. + 25 June 2021: Wouter - Fix up permissions on rpl data file in tests. - Fix testbound newline treatment in moment_read and tempfile write. diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c index 0bbdeeb6b..4bea54e6a 100644 --- a/pythonmod/pythonmod.c +++ b/pythonmod/pythonmod.c @@ -245,6 +245,11 @@ cleanup: /* clear the exception, by not restoring it */ /* Restore the exception state */ /* PyErr_Restore(exc_typ, exc_val, exc_tb); */ + /* when using PyErr_Restore there is no need to Py_XDECREF for + * these 3 pointers. */ + Py_XDECREF(exc_typ); + Py_XDECREF(exc_val); + Py_XDECREF(exc_tb); } int pythonmod_init(struct module_env* env, int id)