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/Image.c | |
parent | d9e85385fd083ef11ccc4ffa06f9120599f18510 (diff) |
more memory leak fixes, though only a few are likely to happen
Diffstat (limited to 'source/blender/python/api2_2x/Image.c')
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 17 |
1 files changed, 11 insertions, 6 deletions
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" ); |