Skip to content

Commit 7acec08

Browse files
committed
Use py::object (reinterpret_steal) for PyObject_CallObject return values to avoid leaking Python objects during scalar UDF execution.
1 parent 3f1f615 commit 7acec08

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/duckdb_py/python_udf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static scalar_function_t CreateNativeFunction(PyObject *function, PythonExceptio
326326
}
327327

328328
// Call the function
329-
auto ret = PyObject_CallObject(function, bundled_parameters.ptr());
329+
auto ret = py::reinterpret_steal<py::object>(PyObject_CallObject(function, bundled_parameters.ptr()));
330330
if (ret == nullptr && PyErr_Occurred()) {
331331
if (exception_handling == PythonExceptionHandling::FORWARD_ERROR) {
332332
auto exception = py::error_already_set();

0 commit comments

Comments
 (0)