diff --git a/src/converter/callback.cpp b/src/converter/callback.cpp index 68ea32f1..0ff0c29a 100644 --- a/src/converter/callback.cpp +++ b/src/converter/callback.cpp @@ -66,6 +66,13 @@ namespace detail , lvalue_from_python_registration*const& converters) { ref holder(source); + if (source->ob_refcnt <= 2) + { + PyErr_SetString( + PyExc_ReferenceError + , const_cast("Attempt to return dangling internal reference")); + throw error_already_set(); + } void* result = find(source, converters); if (!result) {