diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-05-28 01:33:48 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-05-28 01:33:48 +0400 |
commit | bcc314311969959df482dd5525703533d875d023 (patch) | |
tree | 5e5a622471e0214b3ba481ba503ecee1cfa6b06c /source/blender/python/api2_2x/Scene.c | |
parent | d9e85385fd083ef11ccc4ffa06f9120599f18510 (diff) |
more memory leak fixes, though only a few are likely to happen
Diffstat (limited to 'source/blender/python/api2_2x/Scene.c')
-rw-r--r-- | source/blender/python/api2_2x/Scene.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index b692c391520..39a7f0d77f4 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -282,11 +282,13 @@ static int Scene_setLayerMask( BPy_Scene * self, PyObject * value ) static PyObject *Scene_getLayerList( BPy_Scene * self ) { - PyObject *laylist = PyList_New( 0 ), *item; + PyObject *laylist, *item; int layers, bit = 0, val = 0; SCENE_DEL_CHECK_PY(self); + laylist = PyList_New( 0 ); + if( !laylist ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, "couldn't create pylist!" ) ); @@ -677,11 +679,12 @@ static PyObject *M_Scene_Get( PyObject * self, PyObject * args ) while( scene_iter ) { pyobj = Scene_CreatePyObject( scene_iter ); - if( !pyobj ) + if( !pyobj ) { + Py_DECREF(sce_pylist); return ( EXPP_ReturnPyObjError ( PyExc_MemoryError, "couldn't create PyString" ) ); - + } PyList_SET_ITEM( sce_pylist, index, pyobj ); scene_iter = scene_iter->id.next; @@ -927,7 +930,7 @@ static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args ) static PyObject *Scene_getChildren( BPy_Scene * self ) { Scene *scene = self->scene; - PyObject *pylist = PyList_New( 0 ); + PyObject *pylist; PyObject *bpy_obj; Object *object; Base *base; @@ -940,7 +943,8 @@ static PyObject *Scene_getChildren( BPy_Scene * self ) SCENE_DEL_CHECK_PY(self); - + pylist = PyList_New( 0 ); + base = scene->base.first; while( base ) { @@ -948,12 +952,13 @@ static PyObject *Scene_getChildren( BPy_Scene * self ) bpy_obj = Object_CreatePyObject( object ); - if( !bpy_obj ) + if( !bpy_obj ) { + Py_DECREF(pylist); return EXPP_ReturnPyObjError( PyExc_RuntimeError, "couldn't create new object wrapper" ); - + } PyList_Append( pylist, bpy_obj ); - Py_XDECREF( bpy_obj ); /* PyList_Append incref'ed it */ + Py_DECREF( bpy_obj ); /* PyList_Append incref'ed it */ base = base->next; } |