Submitted By: Christopher A. Craig
Fillin some missing decrefs.
return NULL;
assert(PyFloat_CheckExact(tmp));
new = type->tp_alloc(type, 0);
- if (new == NULL)
+ if (new == NULL) {
+ Py_DECREF(tmp);
return NULL;
+ }
((PyFloatObject *)new)->ob_fval = ((PyFloatObject *)tmp)->ob_fval;
Py_DECREF(tmp);
return new;
}
new = type->tp_alloc(type, 0);
- if (new == NULL)
+ if (new == NULL) {
+ Py_DECREF(tmp);
return NULL;
+ }
((PyIntObject *)new)->ob_ival = ival;
Py_DECREF(tmp);
return new;
if (n < 0)
n = -n;
new = (PyLongObject *)type->tp_alloc(type, n);
- if (new == NULL)
+ if (new == NULL) {
+ Py_DECREF(tmp);
return NULL;
+ }
assert(PyLong_Check(new));
new->ob_size = tmp->ob_size;
for (i = 0; i < n; i++)
return NULL;
assert(PyUnicode_Check(tmp));
pnew = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length);
- if (pnew == NULL)
+ if (pnew == NULL) {
+ Py_DECREF(tmp);
return NULL;
+ }
pnew->str = PyMem_NEW(Py_UNICODE, n+1);
if (pnew->str == NULL) {
_Py_ForgetReference((PyObject *)pnew);
PyObject_Del(pnew);
+ Py_DECREF(tmp);
return PyErr_NoMemory();
}
Py_UNICODE_COPY(pnew->str, tmp->str, n+1);