From 89088937a7082674e9cb1b8a1a0906aaa67ec837 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Sat, 1 Apr 2017 18:25:04 +0900 Subject: [PATCH] Avoid memory leakage in smart pointers wrapper --- modules/python/src2/cv2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 4788ef1b5e..bfd23b7e78 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1274,14 +1274,16 @@ PyObject* pyopencv_from(const Moments& m) template PyObject* pyopencv_from(const cv::Ptr& p) { - if (!p) return Py_None; + if (!p) + Py_RETURN_NONE; return pyopencv_from(*p); } template bool pyopencv_to(PyObject *o, Ptr& p, const char *name) { - if (!o || o == Py_None) return true; + if (!o || o == Py_None) + return true; p = makePtr(); return pyopencv_to(o, *p, name); }