=== Bugfix ===
authorMartin Poirier <theeth@yahoo.com>
Mon, 21 May 2007 19:42:11 +0000 (19:42 +0000)
committerMartin Poirier <theeth@yahoo.com>
Mon, 21 May 2007 19:42:11 +0000 (19:42 +0000)
Coverity bugfix (missing NULL check) and ref counting errors. (on module constants, so not really leaking, just not good.)

source/blender/python/api2_2x/Armature.c
source/blender/python/api2_2x/Pose.c
source/blender/python/api2_2x/constant.c

index d4d687f7306e386fc393671cc24e9747f9b71a7d..98b64d7554c0249481eb550becb7fc2a223ed941 100644 (file)
@@ -1373,30 +1373,30 @@ PyObject *Armature_Init(void)
 
        //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
index 2b4f67c9b8c1aff80c13195cb869db0aae5da256..fe60b04b5ff453712a9fdecf18773d6a264fb08e 100644 (file)
@@ -1236,11 +1236,11 @@ PyObject *Pose_Init(void)
 
        //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;
 }
index 0162ad99b6c1bd348c30470f0cc3965f5318ad96..2f74007f617e56dbd71e5e85b21ab5f774239370 100644 (file)
@@ -245,17 +245,23 @@ int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value)
 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;
 }