[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10753] trunk/blender/source/blender/ python/api2_2x: === Bugfix ===

Martin Poirier theeth at yahoo.com
Mon May 21 21:42:11 CEST 2007


Revision: 10753
          https://svn.blender.org//revision/?rev=10753&view=rev
Author:   theeth
Date:     2007-05-21 21:42:11 +0200 (Mon, 21 May 2007)

Log Message:
-----------
=== Bugfix ===

Coverity bugfix (missing NULL check) and ref counting errors. (on module constants, so not really leaking, just not good.)

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Armature.c
    trunk/blender/source/blender/python/api2_2x/Pose.c
    trunk/blender/source/blender/python/api2_2x/constant.c

Modified: trunk/blender/source/blender/python/api2_2x/Armature.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Armature.c	2007-05-21 19:41:14 UTC (rev 10752)
+++ trunk/blender/source/blender/python/api2_2x/Armature.c	2007-05-21 19:42:11 UTC (rev 10753)
@@ -1373,30 +1373,30 @@
 
 	//Add CONSTANTS to the module
 	PyModule_AddObject(module, "CONNECTED", 
-		EXPP_incr_ret(PyConstant_NewInt("CONNECTED", BONE_CONNECTED)));
+		PyConstant_NewInt("CONNECTED", BONE_CONNECTED));
 	PyModule_AddObject(module, "HINGE", 
-		EXPP_incr_ret(PyConstant_NewInt("HINGE", BONE_HINGE)));
+		PyConstant_NewInt("HINGE", BONE_HINGE));
 	PyModule_AddObject(module, "NO_DEFORM", 
-		EXPP_incr_ret(PyConstant_NewInt("NO_DEFORM", BONE_NO_DEFORM)));
+		PyConstant_NewInt("NO_DEFORM", BONE_NO_DEFORM));
 	PyModule_AddObject(module, "MULTIPLY", 
-		EXPP_incr_ret(PyConstant_NewInt("MULTIPLY", BONE_MULT_VG_ENV)));
+		PyConstant_NewInt("MULTIPLY", BONE_MULT_VG_ENV));
 	PyModule_AddObject(module, "HIDDEN_EDIT", 
-		EXPP_incr_ret(PyConstant_NewInt("HIDDEN_EDIT", BONE_HIDDEN_A)));
+		PyConstant_NewInt("HIDDEN_EDIT", BONE_HIDDEN_A));
 	PyModule_AddObject(module, "ROOT_SELECTED", 
-		EXPP_incr_ret(PyConstant_NewInt("ROOT_SELECTED", BONE_ROOTSEL)));
+		PyConstant_NewInt("ROOT_SELECTED", BONE_ROOTSEL));
 	PyModule_AddObject(module, "BONE_SELECTED", 
-		EXPP_incr_ret(PyConstant_NewInt("BONE_SELECTED", BONE_SELECTED)));
+		PyConstant_NewInt("BONE_SELECTED", BONE_SELECTED));
 	PyModule_AddObject(module, "TIP_SELECTED", 
-		EXPP_incr_ret(PyConstant_NewInt("TIP_SELECTED", BONE_TIPSEL)));
+		PyConstant_NewInt("TIP_SELECTED", BONE_TIPSEL));
 
 	PyModule_AddObject(module, "OCTAHEDRON", 
-		EXPP_incr_ret(PyConstant_NewInt("OCTAHEDRON", ARM_OCTA)));
+		PyConstant_NewInt("OCTAHEDRON", ARM_OCTA));
 	PyModule_AddObject(module, "STICK", 
-		EXPP_incr_ret(PyConstant_NewInt("STICK", ARM_LINE)));
+		PyConstant_NewInt("STICK", ARM_LINE));
 	PyModule_AddObject(module, "BBONE", 
-		EXPP_incr_ret(PyConstant_NewInt("BBONE", ARM_B_BONE)));
+		PyConstant_NewInt("BBONE", ARM_B_BONE));
 	PyModule_AddObject(module, "ENVELOPE", 
-		EXPP_incr_ret(PyConstant_NewInt("ENVELOPE", ARM_ENVELOPE)));
+		PyConstant_NewInt("ENVELOPE", ARM_ENVELOPE));
 
 	//Add SUBMODULES to the module
 	dict = PyModule_GetDict( module ); //borrowed

Modified: trunk/blender/source/blender/python/api2_2x/Pose.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Pose.c	2007-05-21 19:41:14 UTC (rev 10752)
+++ trunk/blender/source/blender/python/api2_2x/Pose.c	2007-05-21 19:42:11 UTC (rev 10753)
@@ -1236,11 +1236,11 @@
 
 	//Add CONSTANTS to the module
 	PyModule_AddObject(module, "ROT", 
-		EXPP_incr_ret(PyConstant_NewInt("ROT", POSE_ROT)));
+		PyConstant_NewInt("ROT", POSE_ROT));
 	PyModule_AddObject(module, "LOC", 
-		EXPP_incr_ret(PyConstant_NewInt("LOC", POSE_LOC)));
+		PyConstant_NewInt("LOC", POSE_LOC));
 	PyModule_AddObject(module, "SIZE", 
-		EXPP_incr_ret(PyConstant_NewInt("SIZE", POSE_SIZE)));
+		PyConstant_NewInt("SIZE", POSE_SIZE));
 
 	return module;
 }

Modified: trunk/blender/source/blender/python/api2_2x/constant.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/constant.c	2007-05-21 19:41:14 UTC (rev 10752)
+++ trunk/blender/source/blender/python/api2_2x/constant.c	2007-05-21 19:42:11 UTC (rev 10753)
@@ -245,17 +245,23 @@
 PyObject *PyConstant_NewInt(char *name, int value)
 {
         PyObject *constant = PyConstant_New();
-                
-        PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
-		PyConstant_Insert((BPy_constant*)constant, "value", PyInt_FromLong(value));
-        return EXPP_incr_ret(constant);
+
+		if (constant)
+		{                
+			PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
+			PyConstant_Insert((BPy_constant*)constant, "value", PyInt_FromLong(value));
+		}
+		return constant;
 }
 //This is a helper function for generating constants......
 PyObject *PyConstant_NewString(char *name, char *value)
 {
-        PyObject *constant = PyConstant_New();
-       
-        PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
-		PyConstant_Insert((BPy_constant*)constant, "value", PyString_FromString(value));
-        return EXPP_incr_ret(constant);
+		PyObject *constant = PyConstant_New();
+
+		if (constant)
+		{
+			PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
+			PyConstant_Insert((BPy_constant*)constant, "value", PyString_FromString(value));
+		}
+		return constant;
 }





More information about the Bf-blender-cvs mailing list