Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-05-28 01:33:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-05-28 01:33:48 +0400
commitbcc314311969959df482dd5525703533d875d023 (patch)
tree5e5a622471e0214b3ba481ba503ecee1cfa6b06c
parentd9e85385fd083ef11ccc4ffa06f9120599f18510 (diff)
more memory leak fixes, though only a few are likely to happen
-rw-r--r--source/blender/python/api2_2x/Camera.c5
-rw-r--r--source/blender/python/api2_2x/Curve.c7
-rw-r--r--source/blender/python/api2_2x/Effect.c3
-rw-r--r--source/blender/python/api2_2x/Font.c5
-rwxr-xr-xsource/blender/python/api2_2x/Group.c5
-rw-r--r--source/blender/python/api2_2x/Image.c17
-rw-r--r--source/blender/python/api2_2x/Ipo.c3
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c2
-rw-r--r--source/blender/python/api2_2x/Lamp.c6
-rw-r--r--source/blender/python/api2_2x/Lattice.c5
-rw-r--r--source/blender/python/api2_2x/Material.c5
-rw-r--r--source/blender/python/api2_2x/Mesh.c9
-rw-r--r--source/blender/python/api2_2x/NMesh.c20
-rw-r--r--source/blender/python/api2_2x/Scene.c21
-rw-r--r--source/blender/python/api2_2x/Sound.c5
-rw-r--r--source/blender/python/api2_2x/Text.c5
-rw-r--r--source/blender/python/api2_2x/Texture.c5
-rw-r--r--source/blender/python/api2_2x/gen_utils.c2
-rw-r--r--source/blender/python/api2_2x/sceneSequence.c21
-rw-r--r--source/blender/python/api2_2x/windowTheme.c5
20 files changed, 97 insertions, 59 deletions
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index f5cd3a0995f..3ed11288980 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -304,11 +304,12 @@ static PyObject *M_Camera_Get( PyObject * self, PyObject * args )
while( cam_iter ) {
pyobj = Camera_CreatePyObject( cam_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(cam_pylist);
return EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Camera PyObject" );
-
+ }
PyList_SET_ITEM( cam_pylist, index, pyobj );
cam_iter = cam_iter->id.next;
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 04ed142f4dd..109a4572387 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -481,7 +481,7 @@ static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args )
static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
{
- PyObject *liste = PyList_New( 0 ); /* return values */
+ PyObject *liste;
PyObject *item;
Nurb *ptrnurb;
@@ -498,7 +498,7 @@ static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
/* if no nurbs in this curve obj */
if( !self->curve->nurb.first )
- return liste;
+ return PyList_New( 0 );
/* walk the list of nurbs to find requested numcourbe */
ptrnurb = self->curve->nurb.first;
@@ -513,7 +513,8 @@ static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
if( numpoint >= ptrnurb->pntsu )
return ( EXPP_ReturnPyObjError( PyExc_ValueError,
"point index out of range" ) );
-
+
+ liste = PyList_New( 0 );
if( ptrnurb->bp ) { /* if we are a nurb curve, you get 4 values */
for( i = 0; i < 4; i++ ) {
item = PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i] );
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c
index 1c309ba0851..8c23a4d1544 100644
--- a/source/blender/python/api2_2x/Effect.c
+++ b/source/blender/python/api2_2x/Effect.c
@@ -635,8 +635,7 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args )
if (eff) {
return EffectCreatePyObject( eff, object_iter );
} else { /* didn't find any effect in the given position */
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c
index f7e7b2a2c40..08af60fd9e0 100644
--- a/source/blender/python/api2_2x/Font.c
+++ b/source/blender/python/api2_2x/Font.c
@@ -136,11 +136,12 @@ static PyObject *M_Font_Get( PyObject * self, PyObject * args )
while( vfont_iter ) {
pyobj = Font_CreatePyObject( vfont_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(vfontlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Object" ) );
-
+ }
PyList_SET_ITEM( vfontlist, index, pyobj );
vfont_iter = vfont_iter->id.next;
diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c
index fa43bed58cc..7a6a1562d8b 100755
--- a/source/blender/python/api2_2x/Group.c
+++ b/source/blender/python/api2_2x/Group.c
@@ -426,11 +426,12 @@ PyObject *M_Group_Get( PyObject * self, PyObject * args )
while( group_iter ) {
pyobj = Group_CreatePyObject( group_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(grouplist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Object" ) );
-
+ }
PyList_SET_ITEM( grouplist, index, pyobj );
group_iter = group_iter->id.next;
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index 63a0c0bda1d..4a7ba22a084 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -389,7 +389,7 @@ static PyObject *M_Image_Load( PyObject * self, PyObject * args )
static PyObject *Image_getPixelF( BPy_Image * self, PyObject * args )
{
- PyObject *attr = PyList_New(4);
+ PyObject *attr;
ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
char *pixel; /* image data */
int index; /* offset into image data */
@@ -397,10 +397,6 @@ static PyObject *Image_getPixelF( BPy_Image * self, PyObject * args )
int y = 0;
int pixel_size = 4; /* each pixel is 4 x 8-bits packed in unsigned int */
int i;
-
- if (!attr)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't allocate memory for color list" );
if( !PyArg_ParseTuple( args, "ii", &x, &y ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -425,6 +421,12 @@ static PyObject *Image_getPixelF( BPy_Image * self, PyObject * args )
so we calc ourselves
*/
+ attr = PyList_New(4);
+
+ if (!attr)
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't allocate memory for color list" );
+
index = ( x + y * ibuf->x ) * pixel_size;
pixel = ( char * ) ibuf->rect;
@@ -815,11 +817,14 @@ static PyObject *Image_getFilename( BPy_Image * self )
static PyObject *Image_getSize( BPy_Image * self )
{
ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- PyObject *attr = PyList_New(2);
+ PyObject *attr;
if( !ibuf ) /* didn't work */
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't load image data in Blender" );
+
+ attr = PyList_New(2);
+
if( !attr )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Image.size attribute" );
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 8f6e4061976..466337ff914 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -1678,7 +1678,7 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
struct BezTriple *ptrbt;
int num = 0, pos, i, j;
IpoCurve *icu;
- PyObject *l = PyList_New( 0 ), *pyfloat;
+ PyObject *l, *pyfloat;
if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
return ( EXPP_ReturnPyObjError
@@ -1702,6 +1702,7 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"No bez triple" );
+ l = PyList_New( 0 );
for( i = 0; i < 3; i++ ) {
for( j = 0; j < 3; j++ ) {
pyfloat = PyFloat_FromDouble( ptrbt->vec[i][j] );
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index 29ccb142f9a..7b071ab1f76 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -645,7 +645,7 @@ static PyObject *IpoCurve_getPoints( C_IpoCurve * self )
po = BezTriple_CreatePyObject( bezt );
if( !po ) {
Py_DECREF( list );
- return NULL;
+ return NULL; /* This is okay since the error is alredy set */
}
PyList_SET_ITEM( list, i, po );
}
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index 6be02c45720..84e755b64a0 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -704,10 +704,12 @@ static PyObject *M_Lamp_Get( PyObject * self, PyObject * args )
while( lamp_iter ) {
pyobj = Lamp_CreatePyObject( lamp_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(lamplist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
- "couldn't create PyString" ) );
+ "couldn't create PyLamp" ) );
+ }
PyList_SET_ITEM( lamplist, index, pyobj );
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
index e58967a712b..7ea8aabfc04 100644
--- a/source/blender/python/api2_2x/Lattice.c
+++ b/source/blender/python/api2_2x/Lattice.c
@@ -235,11 +235,12 @@ static PyObject *M_Lattice_Get( PyObject * self, PyObject * args )
while( lat_iter ) {
pyobj = Lattice_CreatePyObject( lat_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(latlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyString" ) );
-
+ }
PyList_SET_ITEM( latlist, index, pyobj );
lat_iter = lat_iter->id.next;
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 7bf80efa680..019c3d750b9 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -309,11 +309,12 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
while( mat_iter ) {
pyobj = Material_CreatePyObject( mat_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(matlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyObject" ) );
-
+ }
PyList_SET_ITEM( matlist, index, pyobj );
mat_iter = mat_iter->id.next;
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index acb95919916..30b67426e6a 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -6200,14 +6200,17 @@ static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
for( i = 0; i < PyList_Size( listObject ); i++ ) {
PyObject *attr = NULL;
- if( !PyArg_Parse( PyList_GetItem( listObject, i ), "i", &num ) )
+ if( !PyArg_Parse( PyList_GetItem( listObject, i ), "i", &num ) ) {
+ Py_DECREF(tempVertexList);
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list integer not parseable" );
+ }
- if( num < 0 || num >= mesh->totvert )
+ if( num < 0 || num >= mesh->totvert ) {
+ Py_DECREF(tempVertexList);
return EXPP_ReturnPyObjError( PyExc_ValueError,
"bad vertex index in list" );
-
+ }
dvert = mesh->dvert + num;
for( k = 0; k < dvert->totweight; k++ ) {
if( dvert->dw[k].def_nr == nIndex ) {
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index 0eb90d348ce..5c86a344896 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -533,10 +533,12 @@ static PyObject *new_NMFace( PyObject * vertexlist )
if( item )
PyList_SET_ITEM( vlcopy, i, item );
- else
+ else {
+ Py_DECREF(vlcopy);
return EXPP_ReturnPyObjError
( PyExc_RuntimeError,
"couldn't get vertex from a PyList" );
+ }
}
} else /* create an empty vertex list */
vlcopy = PyList_New( 0 );
@@ -3808,14 +3810,16 @@ static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args )
if( !
( PyArg_Parse
( ( PyList_GetItem( listObject, x ) ), "i",
- &tempInt ) ) )
+ &tempInt ) ) ) {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list integer not parseable" );
+ }
if( tempInt < 0
- || tempInt >= ( ( Mesh * ) object->data )->totvert )
+ || tempInt >= ( ( Mesh * ) object->data )->totvert ) {
return EXPP_ReturnPyObjError( PyExc_ValueError,
"bad vertex index in list" );
+ }
add_vert_defnr( object, nIndex, tempInt, weight, assignmode );
}
@@ -4013,16 +4017,18 @@ static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args )
if( !
( PyArg_Parse
( ( PyList_GetItem( listObject, x ) ), "i",
- &tempInt ) ) )
+ &tempInt ) ) ) {
+ Py_DECREF(tempVertexList);
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list integer not parseable" );
-
+ }
if( tempInt < 0
|| tempInt >=
- ( ( Mesh * ) object->data )->totvert )
+ ( ( Mesh * ) object->data )->totvert ) {
+ Py_DECREF(tempVertexList);
return EXPP_ReturnPyObjError( PyExc_ValueError,
"bad vertex index in list" );
-
+ }
num = tempInt;
dvert = ( ( Mesh * ) object->data )->dvert + num;
for( i = 0; i < dvert->totweight; i++ ) {
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;
}
diff --git a/source/blender/python/api2_2x/Sound.c b/source/blender/python/api2_2x/Sound.c
index 75e67f94aae..350d04e5a63 100644
--- a/source/blender/python/api2_2x/Sound.c
+++ b/source/blender/python/api2_2x/Sound.c
@@ -243,11 +243,12 @@ static PyObject *M_Sound_Get( PyObject * self, PyObject * args )
while( snd_iter ) {
pyobj = Sound_CreatePyObject( snd_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(snd_list);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyObject" ) );
-
+ }
PyList_SET_ITEM( snd_list, index, pyobj );
snd_iter = snd_iter->id.next;
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index e106bfea482..da4fbe44eb0 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -218,11 +218,12 @@ static PyObject *M_Text_Get( PyObject * self, PyObject * args )
while( txt_iter ) {
pyobj = Text_CreatePyObject( txt_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(txtlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyString" ) );
-
+ }
PyList_SET_ITEM( txtlist, index, pyobj );
txt_iter = txt_iter->id.next;
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index d1636c3d405..607ff6fe008 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -947,11 +947,12 @@ static PyObject *M_Texture_Get( PyObject * self, PyObject * args )
while( tex_iter ) {
pyobj = Texture_CreatePyObject( tex_iter );
- if( !pyobj )
+ if( !pyobj ) {
+ Py_DECREF(tex_pylist);
return EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Texture PyObject" );
-
+ }
PyList_SET_ITEM( tex_pylist, index, pyobj );
tex_iter = tex_iter->id.next;
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 93ceeda13f1..c38e9daeb3f 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -390,7 +390,6 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
char *eventname = NULL;
int i, event = 0;
- list = PyList_New( 0 );
if( !PyArg_ParseTuple( args, "s", &eventname ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -400,6 +399,7 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
if( !slink || !slink->totscript )
return list;
+ list = PyList_New( 0 );
if( !list )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList!" );
diff --git a/source/blender/python/api2_2x/sceneSequence.c b/source/blender/python/api2_2x/sceneSequence.c
index e8b9b99c218..e7c8abe72a2 100644
--- a/source/blender/python/api2_2x/sceneSequence.c
+++ b/source/blender/python/api2_2x/sceneSequence.c
@@ -512,23 +512,30 @@ static PyObject *Sequence_getImages( BPy_Sequence * self )
Strip *strip;
StripElem *se;
int i;
- PyObject *attr;
+ PyObject *list, *ret;
+
+ if (self->seq->type != SEQ_IMAGE) {
+ list = PyList_New(0);
+ ret= Py_BuildValue( "sO", "", list);
+ Py_DECREF(list);
+ return ret;
+ }
- if (self->seq->type != SEQ_IMAGE)
- return PyList_New(0);
/*return EXPP_ReturnPyObjError( PyExc_TypeError,
"Sequence is not an image type" );*/
strip = self->seq->strip;
se = strip->stripdata;
- attr = PyList_New(strip->len);
+ list = PyList_New(strip->len);
for (i=0; i<strip->len; i++, se++) {
- PyList_SetItem( attr, i, PyString_FromString(se->name) );
+ PyList_SetItem( list, i, PyString_FromString(se->name) );
}
-
- return attr;
+
+ ret= Py_BuildValue( "sO", strip->dir, list);
+ Py_DECREF(list);
+ return ret;
}
diff --git a/source/blender/python/api2_2x/windowTheme.c b/source/blender/python/api2_2x/windowTheme.c
index 813507e5188..7ae7a0a32de 100644
--- a/source/blender/python/api2_2x/windowTheme.c
+++ b/source/blender/python/api2_2x/windowTheme.c
@@ -643,11 +643,12 @@ static PyObject *M_Theme_Get( PyObject * self, PyObject * args )
pytheme = PyObject_New( BPy_Theme, &Theme_Type );
pytheme->theme = iter;
- if( !pytheme )
+ if( !pytheme ) {
+ Py_DECREF(list);
return EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Theme PyObject" );
-
+ }
PyList_SET_ITEM( list, index, ( PyObject * ) pytheme );
iter = iter->next;