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/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp | 3 ++- .../freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp | 3 ++- .../python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp | 3 ++- .../intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) (limited to 'source/blender/freestyle/intern/python/UnaryFunction0D') diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp index cfc4bb24a56..3d0eadfa9a3 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -197,7 +197,8 @@ int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self) void UnaryFunction0DDouble___dealloc__(BPy_UnaryFunction0DDouble* self) { - delete self->uf0D_double; + if (self->uf0D_double) + delete self->uf0D_double; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp index ac5b1257167..543d6dc57a7 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature* self) void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature* self) { - delete self->uf0D_edgenature; + if (self->uf0D_edgenature) + delete self->uf0D_edgenature; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp index 13285bdcf88..949a88a49af 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -169,7 +169,8 @@ int UnaryFunction0DFloat___init__(BPy_UnaryFunction0DFloat* self) void UnaryFunction0DFloat___dealloc__(BPy_UnaryFunction0DFloat* self) { - delete self->uf0D_float; + if (self->uf0D_float) + delete self->uf0D_float; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp index 15863eb3600..1041f1053de 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DId___init__(BPy_UnaryFunction0DId* self) void UnaryFunction0DId___dealloc__(BPy_UnaryFunction0DId* self) { - delete self->uf0D_id; + if (self->uf0D_id) + delete self->uf0D_id; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index bbb7e2d61a2..64b4d53fe2e 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DMaterial___init__(BPy_UnaryFunction0DMaterial* self) void UnaryFunction0DMaterial___dealloc__(BPy_UnaryFunction0DMaterial* self) { - delete self->uf0D_material; + if (self->uf0D_material) + delete self->uf0D_material; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index 1b8535318af..b0ecbc79cd2 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DUnsigned___init__(BPy_UnaryFunction0DUnsigned* self) void UnaryFunction0DUnsigned___dealloc__(BPy_UnaryFunction0DUnsigned* self) { - delete self->uf0D_unsigned; + if (self->uf0D_unsigned) + delete self->uf0D_unsigned; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp index a2bda09180a..946210ee381 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -146,7 +146,8 @@ int UnaryFunction0DVec2f___init__(BPy_UnaryFunction0DVec2f* self) void UnaryFunction0DVec2f___dealloc__(BPy_UnaryFunction0DVec2f* self) { - delete self->uf0D_vec2f; + if (self->uf0D_vec2f) + delete self->uf0D_vec2f; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp index b484d872627..d3d0a6593ca 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f* self) void UnaryFunction0DVec3f___dealloc__(BPy_UnaryFunction0DVec3f* self) { - delete self->uf0D_vec3f; + if (self->uf0D_vec3f) + delete self->uf0D_vec3f; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp index 9640bf23e43..de77cdd686b 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -140,7 +140,8 @@ int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape* void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape* self) { - delete self->uf0D_vectorviewshape; + if (self->uf0D_vectorviewshape) + delete self->uf0D_vectorviewshape; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp index d8be0411c9e..2fe1e61dcf3 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -146,7 +146,8 @@ int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape* self) void UnaryFunction0DViewShape___dealloc__(BPy_UnaryFunction0DViewShape* self) { - delete self->uf0D_viewshape; + if (self->uf0D_viewshape) + delete self->uf0D_viewshape; UnaryFunction0D_Type.tp_dealloc((PyObject*)self); } -- cgit v1.2.3