diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 12:33:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 12:35:16 +0300 |
commit | de6b546e15523a0a4ab6da7e5beebaeb15cfa617 (patch) | |
tree | 0f3eb11b1b06d4da2c939c1d268d2cb1ee07d963 /source/blender/freestyle/intern/python/UnaryFunction1D | |
parent | e0db0f84ac28ce14ead649140023e46e65dfc2f7 (diff) |
Fix 8 memory leaks from bad PyList_Append use
Diffstat (limited to 'source/blender/freestyle/intern/python/UnaryFunction1D')
-rw-r--r-- | source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp index a028952fa69..c15d974e771 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -142,18 +142,12 @@ static PyObject *UnaryFunction1DVectorViewShape___call__(BPy_UnaryFunction1DVect } return NULL; } - PyObject *list = PyList_New(0); - PyObject *item; - for (unsigned int i = 0; i < self->uf1D_vectorviewshape->result.size(); i++) { + + const unsigned int list_len = self->uf1D_vectorviewshape->result.size(); + PyObject *list = PyList_New(list_len); + for (unsigned int i = 0; i < list_len; i++) { ViewShape *v = self->uf1D_vectorviewshape->result[i]; - if (v) { - item = BPy_ViewShape_from_ViewShape(*v); - } - else { - item = Py_None; - Py_INCREF(item); - } - PyList_Append(list, item); + PyList_SET_ITEM(list, i, v ? BPy_ViewShape_from_ViewShape(*v) : (Py_INCREF(Py_None), Py_None)); } return list; |