summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@ispras.ru>2019-02-12 16:06:43 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2019-02-12 16:06:43 (GMT)
commit16f842da3c862d76a1177bd8ef9579703c24fa5a (patch)
tree476f517535ce737c62d0d4dcc19a404cc136839f /Python/pystate.c
parentb01786c8812c4cc24dd561b5941025bdd6f444c0 (diff)
downloadcpython-16f842da3c862d76a1177bd8ef9579703c24fa5a.zip
cpython-16f842da3c862d76a1177bd8ef9579703c24fa5a.tar.gz
cpython-16f842da3c862d76a1177bd8ef9579703c24fa5a.tar.bz2
bpo-35972: _xxsubinterpreters: Fix potential integer truncation on 32-bit in channel_send() (gh-11822)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 4dc3b81..f0b2a67 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1467,13 +1467,17 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data)
static PyObject *
_new_long_object(_PyCrossInterpreterData *data)
{
- return PyLong_FromLongLong((intptr_t)(data->data));
+ return PyLong_FromSsize_t((Py_ssize_t)(data->data));
}
static int
_long_shared(PyObject *obj, _PyCrossInterpreterData *data)
{
- int64_t value = PyLong_AsLongLong(obj);
+ /* Note that this means the size of shareable ints is bounded by
+ * sys.maxsize. Hence on 32-bit architectures that is half the
+ * size of maximum shareable ints on 64-bit.
+ */
+ Py_ssize_t value = PyLong_AsSsize_t(obj);
if (value == -1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
PyErr_SetString(PyExc_OverflowError, "try sending as bytes");