summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-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);
}