From 45219c6b8fd4bf593cd6a64ed77cd1837362e5b3 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 2 Mar 2022 14:14:52 -0500 Subject: [PATCH] fix: potential memory leak in pypy (#3774) --- include/pybind11/pybind11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 235fa7c11..e349bfdc9 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -2729,9 +2729,9 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char * d.ptr()); if (result == nullptr) throw error_already_set(); + Py_DECREF(result); if (d["self"].is_none()) return function(); - Py_DECREF(result); #endif return override;