diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 18:27:06 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 18:27:06 (GMT) |
commit | 82a95277b8f8cb8245abdd14decff9d44d13d25c (patch) | |
tree | d223cd7cd9a745b25d5c364bbe26bec1140f2e0f /Objects/longobject.c | |
parent | 4e1de16f88cd8b99b2d154e647b63f2f6f8b58ae (diff) | |
download | cpython-82a95277b8f8cb8245abdd14decff9d44d13d25c.zip cpython-82a95277b8f8cb8245abdd14decff9d44d13d25c.tar.gz cpython-82a95277b8f8cb8245abdd14decff9d44d13d25c.tar.bz2 |
Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index ba23599..9d6474c 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4281,6 +4281,11 @@ long_lshift(PyObject *v, PyObject *w) PyErr_SetString(PyExc_ValueError, "negative shift count"); return NULL; } + + if (Py_SIZE(a) == 0) { + return PyLong_FromLong(0); + } + /* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */ wordshift = shiftby / PyLong_SHIFT; remshift = shiftby - wordshift * PyLong_SHIFT; |