more memory leak fixes, though only a few are likely to happen
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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] );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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" );
|
||||
|
||||
@@ -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] );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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++ ) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!" );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user