From ffb428f8bd9bca9421bde073fcdeff0c941319c3 Mon Sep 17 00:00:00 2001 From: Duc Le Date: Mon, 15 May 2023 16:36:56 +0100 Subject: [PATCH] Fix Py_None increment bug #270 --- CHANGELOG.rst | 2 ++ c/_euphonic.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 55ee0fa9a..913bb5c4b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ - Allow ``color`` to be passed as an extra kwarg to ``plot_1d`` and ``plot_1d_to_axis``. Previously this caused a ``TypeError``. + - Fix bug where ``Py_None`` was not incremented before returning from + ``calculate_phonons()`` in the C-extension causing a deallocation crash `v1.2.0 `_ ------ diff --git a/c/_euphonic.c b/c/_euphonic.c index 2a93b2f7e..84ce901f4 100644 --- a/c/_euphonic.c +++ b/c/_euphonic.c @@ -300,7 +300,7 @@ static PyObject *calculate_phonons(PyObject *self, PyObject *args) { Py_DECREF(py_dipole_init_data); } - return Py_None; + Py_RETURN_NONE; } static PyMethodDef _euphonic_methods[] = {