From 8503f75212dbe4d84183e3ca2b76cc215513ad66 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 19 Jan 2011 01:43:45 +0000 Subject: [PATCH] Fixed leak of dims in MatND creates --- modules/python/cv.cpp | 2 ++ tests/python/leak2.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/python/cv.cpp b/modules/python/cv.cpp index 61cdd54d1..6cbe1d94d 100644 --- a/modules/python/cv.cpp +++ b/modules/python/cv.cpp @@ -2793,6 +2793,7 @@ static PyObject *pycvCreateMatNDHeader(PyObject *self, PyObject *args) m->data = Py_None; Py_INCREF(m->data); + delete [] dims.i; return (PyObject*)m; } @@ -2806,6 +2807,7 @@ static PyObject *pycvCreateMatND(PyObject *self, PyObject *args) return NULL; cvmatnd_t *m = PyObject_NEW(cvmatnd_t, &cvmatnd_Type); ERRWRAP(m->a = cvCreateMatND(dims.count, dims.i, type)); + delete [] dims.i; return pythonize_CvMatND(m); } diff --git a/tests/python/leak2.py b/tests/python/leak2.py index 2a3d4ae21..a67352f19 100644 --- a/tests/python/leak2.py +++ b/tests/python/leak2.py @@ -6,5 +6,5 @@ while True: for i in range(4000): a = cv.CreateImage((1024,1024), cv.IPL_DEPTH_8U, 1) b = cv.CreateMat(1024, 1024, cv.CV_8UC1) - # c = cv.CreateMatND([1024,1024], cv.CV_8UC1) + c = cv.CreateMatND([1024,1024], cv.CV_8UC1) print "pause..."