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:
authorStephen Swaney <sswaney@centurytel.net>2004-12-02 02:09:59 +0300
committerStephen Swaney <sswaney@centurytel.net>2004-12-02 02:09:59 +0300
commit70c386cddf47c5dc9491c15d04dea97c2e8e51f4 (patch)
treebb245b77871bfd0e112904271ba986cce36b65c7 /source/blender/python/api2_2x/euler.c
parent8fc85d9c8f71cf8a063834c5a69b8f747d98e46c (diff)
bugfix: #1930 Mathutils.Euler constructor fails to initialize class variables
Euler object was holding pointer to bad memory. Euler now owns internal array memory and frees it in destructor.
Diffstat (limited to 'source/blender/python/api2_2x/euler.c')
-rw-r--r--source/blender/python/api2_2x/euler.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/euler.c b/source/blender/python/api2_2x/euler.c
index d55b5814270..6b72460ccd4 100644
--- a/source/blender/python/api2_2x/euler.c
+++ b/source/blender/python/api2_2x/euler.c
@@ -150,6 +150,9 @@ PyObject *Euler_Zero( EulerObject * self )
static void Euler_dealloc( EulerObject * self )
{
+ /* since we own this memory... */
+ PyMem_Free( self->eul );
+
PyObject_DEL( self );
}
@@ -330,13 +333,25 @@ PyObject *newEulerObject( float *eul )
self = PyObject_NEW( EulerObject, &euler_Type );
+ /*
+ we own the self->eul memory and will free it later.
+ if we received an input arg, copy to our internal array
+ */
+
+ self->eul = PyMem_Malloc( 3 * sizeof( float ) );
+ if( ! self->eul )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "newEulerObject:PyMem_Malloc failed" );
+
if( !eul ) {
- self->eul = PyMem_Malloc( 3 * sizeof( float ) );
for( x = 0; x < 3; x++ ) {
self->eul[x] = 0.0f;
}
- } else
- self->eul = eul;
+ } else{
+ for( x = 0; x < 3; x++){
+ self->eul[x] = eul[x];
+ }
+ }
return ( PyObject * ) self;
}