gh-99845: _PyObject_DictPointer(): fix dictoffset cast (#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.
This commit is contained in:
Victor Stinner 2022-12-01 14:07:58 +01:00 committed by GitHub
parent 88b754b605
commit 9707bf228e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1076,8 +1076,9 @@ _PyObject_DictPointer(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);
}