2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Assert refcount before decrement (#64)

Assert reference count before decrementing it.
This commit is contained in:
WKarel
2016-09-29 13:48:46 +02:00
committed by Stefan Seefeld
parent aaf0d220ae
commit bc2f77a3db
2 changed files with 3 additions and 0 deletions

View File

@@ -422,6 +422,7 @@ inline api::object_base& api::object_base::operator=(api::object_base const& rhs
inline api::object_base::~object_base()
{
assert( Py_REFCNT(m_ptr) > 0 );
Py_DECREF(m_ptr);
}

View File

@@ -27,12 +27,14 @@ inline T* xincref(T* p)
template <class T>
inline void decref(T* p)
{
assert( Py_REFCNT(python::upcast<PyObject>(p)) > 0 );
Py_DECREF(python::upcast<PyObject>(p));
}
template <class T>
inline void xdecref(T* p)
{
assert( !p || Py_REFCNT(python::upcast<PyObject>(p)) > 0 );
Py_XDECREF(python::upcast<PyObject>(p));
}