From eae3ed0c08e1a4d05eefe7976b93844b3fcfb24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Ma=C5=A1ek?= Date: Tue, 3 Apr 2018 03:02:21 +0200 Subject: [PATCH] Fix a leak described in issue #11205 --- modules/python/src2/cv2.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index fab60fd03f..b825ca9d50 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1584,6 +1584,8 @@ static void OnChange(int pos, void *param) PyObject *r = PyObject_Call(PyTuple_GetItem(o, 0), args, NULL); if (r == NULL) PyErr_Print(); + else + Py_DECREF(r); Py_DECREF(args); PyGILState_Release(gstate); } @@ -1626,6 +1628,8 @@ static void OnButtonChange(int state, void *param) PyObject *r = PyObject_Call(PyTuple_GetItem(o, 0), args, NULL); if (r == NULL) PyErr_Print(); + else + Py_DECREF(r); Py_DECREF(args); PyGILState_Release(gstate); }