summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-19 15:40:09 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-19 15:40:09 (GMT)
commitfa56e2dc409173b0abf497244977fcaeb1a39b1a (patch)
tree16f631d41a4e32099564e0833b20bfdea902a3fb /Objects/intobject.c
parentf4ca5a2f450edbe2d2f6723d474976077620149f (diff)
downloadcpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.zip
cpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.tar.gz
cpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.tar.bz2
SF # 669553, fix memory (ref) leaks
Will backport.
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r--Objects/intobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index d9e4d31..805f3b7 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -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);
}