=== Bugfix ===

Coverity bugfix (missing NULL check) and ref counting errors. (on module constants, so not really leaking, just not good.)
This commit is contained in:
2007-05-21 19:42:11 +00:00
parent 21bc08a0bb
commit c4f6ac80df
3 changed files with 30 additions and 24 deletions

View 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;
}