diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 15:40:29 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 15:40:29 (GMT) |
commit | 583c6e860c1f9eee81ebf09fd87e0f921e8c0dd2 (patch) | |
tree | 6d8282d92bd4c33a7052d38cf36d9e14f1e2e4cd /Objects | |
parent | 2be278c70c128f67e6fa7a1790543a8990f384b8 (diff) | |
download | cpython-583c6e860c1f9eee81ebf09fd87e0f921e8c0dd2.zip cpython-583c6e860c1f9eee81ebf09fd87e0f921e8c0dd2.tar.gz cpython-583c6e860c1f9eee81ebf09fd87e0f921e8c0dd2.tar.bz2 |
Issue #27214: Fix potential bug and remove useless optimization in long_invert. Thanks Oren Milman.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 38e7072..89b6862 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 * |