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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user