diff options
author | Martin Poirier <theeth@yahoo.com> | 2007-05-21 23:42:11 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2007-05-21 23:42:11 +0400 |
commit | c4f6ac80df03aa236f8dbfe7dc92f6e06121cceb (patch) | |
tree | 4fb4a8c79ff85f21a3d894b9be122a4622a4f3f6 /source/blender/python/api2_2x/constant.c | |
parent | 21bc08a0bb39638e13fa19109a22e2d9fb20579e (diff) |
=== Bugfix ===
Coverity bugfix (missing NULL check) and ref counting errors. (on module constants, so not really leaking, just not good.)
Diffstat (limited to 'source/blender/python/api2_2x/constant.c')
-rw-r--r-- | source/blender/python/api2_2x/constant.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c index 0162ad99b6c..2f74007f617 100644 --- a/source/blender/python/api2_2x/constant.c +++ b/source/blender/python/api2_2x/constant.c @@ -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; } |