Skip to content

Commit 9707bf2

Browse files
authored
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.
1 parent 88b754b commit 9707bf2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: Objects/object.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,9 @@ _PyObject_DictPointer(PyObject *obj)
10761076
tsize = -tsize;
10771077
}
10781078
size_t size = _PyObject_VAR_SIZE(tp, tsize);
1079+
assert(size <= (size_t)PY_SSIZE_T_MAX);
1080+
dictoffset += (Py_ssize_t)size;
10791081

1080-
dictoffset += (long)size;
10811082
_PyObject_ASSERT(obj, dictoffset > 0);
10821083
_PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
10831084
}

0 commit comments

Comments
 (0)