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/Interface0D | |
parent | e0db0f84ac28ce14ead649140023e46e65dfc2f7 (diff) |
Fix 8 memory leaks from bad PyList_Append use
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface0D')
-rw-r--r-- | source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 6f47ce93ca8..6845bc3ed12 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -342,13 +342,14 @@ PyDoc_STRVAR(SVertex_normals_doc, static PyObject *SVertex_normals_get(BPy_SVertex *self, void *UNUSED(closure)) { PyObject *py_normals; - set< Vec3r > normals; - - py_normals = PyList_New(0); - normals = self->sv->normals(); - for (set< Vec3r >::iterator set_iterator = normals.begin(); set_iterator != normals.end(); set_iterator++) { - Vec3r v(*set_iterator); - PyList_Append(py_normals, Vector_from_Vec3r(v)); + set< Vec3r > normals = self->sv->normals(); + set< Vec3r >::iterator it; + py_normals = PyList_New(normals.size()); + unsigned int i = 0; + + for (it = normals.begin(); it != normals.end(); it++) { + Vec3r v(*it); + PyList_SET_ITEM(py_normals, i++, Vector_from_Vec3r(v)); } return py_normals; } |