Skip to content

Commit 64dae2e

Browse files
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 9707bf2) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 807b103 commit 64dae2e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Objects/object.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,9 @@ _PyObject_GetDictPtr(PyObject *obj)
10911091
tsize = -tsize;
10921092
}
10931093
size_t size = _PyObject_VAR_SIZE(tp, tsize);
1094+
assert(size <= (size_t)PY_SSIZE_T_MAX);
1095+
dictoffset += (Py_ssize_t)size;
10941096

1095-
dictoffset += (long)size;
10961097
_PyObject_ASSERT(obj, dictoffset > 0);
10971098
_PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
10981099
}

0 commit comments

Comments
 (0)