[Python-checkins] gh-99845: _PyObject_DictPointer(): fix dictoffset cast (GH-99922)

miss-islington webhook-mailer at python.org
Thu Dec 1 08:32:21 EST 2022


https://github.com/python/cpython/commit/64dae2efd5a083d342d744d40ca8d6ebb28bc771
commit: 64dae2efd5a083d342d744d40ca8d6ebb28bc771
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022年12月01日T05:32:15-08:00
summary:
gh-99845: _PyObject_DictPointer(): fix dictoffset cast (GH-99922)
Cast size_t to Py_ssize_t, rather than casting it to long. On 64-bit
Windows, long is 32-bit whereas Py_ssize_t is 64-bit.
(cherry picked from commit 9707bf228e008485a3fbb63aa7ee28cf88014f91)
Co-authored-by: Victor Stinner <vstinner at python.org>
files:
M Objects/object.c
diff --git a/Objects/object.c b/Objects/object.c
index 6d80d6df7410..0bef2e9dfb5e 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1091,8 +1091,9 @@ _PyObject_GetDictPtr(PyObject *obj)
 tsize = -tsize;
 }
 size_t size = _PyObject_VAR_SIZE(tp, tsize);
+ assert(size <= (size_t)PY_SSIZE_T_MAX);
+ dictoffset += (Py_ssize_t)size;
 
- dictoffset += (long)size;
 _PyObject_ASSERT(obj, dictoffset > 0);
 _PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /