diff options
Diffstat (limited to 'sources/shiboken2/libshiboken/autodecref.h')
-rw-r--r-- | sources/shiboken2/libshiboken/autodecref.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/autodecref.h b/sources/shiboken2/libshiboken/autodecref.h index d3353b1e4..498b1aec4 100644 --- a/sources/shiboken2/libshiboken/autodecref.h +++ b/sources/shiboken2/libshiboken/autodecref.h @@ -96,8 +96,10 @@ public: */ void reset(PyObject *other) { - Py_XDECREF(m_pyObj); + // Safely decref m_pyObj. See Py_XSETREF in object.h . + PyObject *_py_tmp = m_pyObj; m_pyObj = other; + Py_XDECREF(_py_tmp); } private: PyObject *m_pyObj; |