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/BPy_SShape.cpp | |
parent | e0db0f84ac28ce14ead649140023e46e65dfc2f7 (diff) |
Fix 8 memory leaks from bad PyList_Append use
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_SShape.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_SShape.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp index e5a38171ecd..11ed07df5de 100644 --- a/source/blender/freestyle/intern/python/BPy_SShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -227,13 +227,14 @@ PyDoc_STRVAR(SShape_vertices_doc, static PyObject *SShape_vertices_get(BPy_SShape *self, void *UNUSED(closure)) { - PyObject *py_vertices = PyList_New(0); vector< SVertex * > vertices = self->ss->getVertexList(); vector< SVertex * >::iterator it; + PyObject *py_vertices = PyList_New(vertices.size()); + unsigned int i = 0; for (it = vertices.begin(); it != vertices.end(); it++) { - PyList_Append(py_vertices, BPy_SVertex_from_SVertex(*(*it))); + PyList_SET_ITEM(py_vertices, i++, BPy_SVertex_from_SVertex(*(*it))); } return py_vertices; @@ -246,13 +247,14 @@ PyDoc_STRVAR(SShape_edges_doc, static PyObject *SShape_edges_get(BPy_SShape *self, void *UNUSED(closure)) { - PyObject *py_edges = PyList_New(0); vector< FEdge * > edges = self->ss->getEdgeList(); vector< FEdge * >::iterator it; + PyObject *py_edges = PyList_New(edges.size()); + unsigned int i = 0; for (it = edges.begin(); it != edges.end(); it++) { - PyList_Append(py_edges, Any_BPy_FEdge_from_FEdge(*(*it))); + PyList_SET_ITEM(py_edges, i++, Any_BPy_FEdge_from_FEdge(*(*it))); } return py_edges; |