summaryrefslogtreecommitdiff
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2016-08-29 16:40:29 +0100
committerMark Dickinson <dickinsm@gmail.com>2016-08-29 16:40:29 +0100
commit334dc5e447f88e20700aeba4cebbde3cdf074eb3 (patch)
treee06769231d2a668c158d7a7881079cbce5e30a33 /Objects/longobject.c
parent415b3926060db352df4690e8526d85dc70afdf85 (diff)
downloadcpython-334dc5e447f88e20700aeba4cebbde3cdf074eb3.tar.gz
Issue #27214: Fix potential bug and remove useless optimization in long_invert. Thanks Oren Milman.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 38e707220a..89b6862605 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4170,8 +4170,10 @@ long_invert(PyLongObject *v)
Py_DECREF(w);
if (x == NULL)
return NULL;
- Py_SIZE(x) = -(Py_SIZE(x));
- return (PyObject *)maybe_small_long(x);
+ _PyLong_Negate(&x);
+ /* No need for maybe_small_long here, since any small
+ longs will have been caught in the Py_SIZE <= 1 fast path. */
+ return (PyObject *)x;
}
static PyObject *