SF # 669553, fix memory (ref) leaks

Will backport.
This commit is contained in:
Neal Norwitz 2003-01-19 15:40:09 +00:00
parent f4ca5a2f45
commit fa56e2dc40
2 changed files with 32 additions and 13 deletions

View file

@ -606,9 +606,16 @@ int_neg(PyIntObject *v)
a = v->ob_ival;
x = -a;
if (a < 0 && x < 0) {
PyObject *o;
if (err_ovf("integer negation"))
return NULL;
return PyNumber_Negative(PyLong_FromLong(a));
o = PyLong_FromLong(a);
if (o != NULL) {
PyObject *result = PyNumber_Negative(o);
Py_DECREF(o);
return result;
}
return NULL;
}
return PyInt_FromLong(x);
}