From 52f639277b527b97eb29f3f91e0f5899fd30d8a2 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 26 Jul 2009 20:20:25 +0000 Subject: Second attempt to fix a null pointer reference in deallocators of built-in types (the first was in revision 21877). When an exception has raised within from the __init__ method of a user-defined class derived from a built-in type (e.g., UnaryPredicate0D and BinaryPredicate1D), some member variables of the base type are left uninitialized, leading to a null pointer reference in the "__dealloc__" function in the base type. To avoid this, pointer checking was added in the deallocators of those built-in types that can be used to define a subclass by a user. --- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp | 3 ++- .../python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp | 3 ++- .../intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) (limited to 'source/blender/freestyle/intern/python/UnaryFunction1D') diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp index 89d79e0b83f..17949073949 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp @@ -237,7 +237,8 @@ int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *ar void UnaryFunction1DDouble___dealloc__(BPy_UnaryFunction1DDouble* self) { - delete self->uf1D_double; + if (self->uf1D_double) + delete self->uf1D_double; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp index 7723be839a4..e704eebc8be 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp @@ -157,7 +157,8 @@ int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyOb } void UnaryFunction1DEdgeNature___dealloc__(BPy_UnaryFunction1DEdgeNature* self) { - delete self->uf1D_edgenature; + if (self->uf1D_edgenature) + delete self->uf1D_edgenature; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp index 2a8d8f9ec75..36296554213 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp @@ -150,7 +150,8 @@ int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args } void UnaryFunction1DFloat___dealloc__(BPy_UnaryFunction1DFloat* self) { - delete self->uf1D_float; + if (self->uf1D_float) + delete self->uf1D_float; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp index 44bf1c5d563..18da07c5bfb 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp @@ -157,7 +157,8 @@ int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject } void UnaryFunction1DUnsigned___dealloc__(BPy_UnaryFunction1DUnsigned* self) { - delete self->uf1D_unsigned; + if (self->uf1D_unsigned) + delete self->uf1D_unsigned; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp index cb4698b1c50..06c17d0f635 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp @@ -163,7 +163,8 @@ int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args } void UnaryFunction1DVec2f___dealloc__(BPy_UnaryFunction1DVec2f* self) { - delete self->uf1D_vec2f; + if (self->uf1D_vec2f) + delete self->uf1D_vec2f; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp index 0d4ce8c6cf1..2fe32c1c311 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp @@ -157,7 +157,8 @@ int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args } void UnaryFunction1DVec3f___dealloc__(BPy_UnaryFunction1DVec3f* self) { - delete self->uf1D_vec3f; + if (self->uf1D_vec3f) + delete self->uf1D_vec3f; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp index a79b70e4593..5b86ea1f4ca 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -171,7 +171,8 @@ int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape* void UnaryFunction1DVectorViewShape___dealloc__(BPy_UnaryFunction1DVectorViewShape* self) { - delete self->uf1D_vectorviewshape; + if (self->uf1D_vectorviewshape) + delete self->uf1D_vectorviewshape; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp index 4c081b8ad64..ff588a9f3b8 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp @@ -172,7 +172,8 @@ int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args) void UnaryFunction1DVoid___dealloc__(BPy_UnaryFunction1DVoid* self) { - delete self->uf1D_void; + if (self->uf1D_void) + delete self->uf1D_void; UnaryFunction1D_Type.tp_dealloc((PyObject*)self); } -- cgit v1.2.3