From be6016a97200d651198a187d1321f16475b907fa Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 10 Mar 2002 06:38:50 +0000 Subject: [PATCH] Prevent dangling reference returns [SVN r13163] --- src/converter/callback.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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) {