File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -582,6 +582,10 @@ class TupleObject(ctypes.Structure):
582582 _fields_ = [
583583 ("ob_type", ctypes.c_void_p),
584584 ("ob_size", ctypes.c_ssize_t),
585+ ]
586+
587+ class TupleItems(ctypes.Structure):
588+ _fields_ = [
585589 ("ob_item0", ctypes.c_void_p),
586590 ("ob_item1", ctypes.c_void_p),
587591 ]
@@ -590,15 +594,19 @@ def ob_type_field(obj):
590594 # Assume ob_type is the last field of PyObject
591595 return id(obj) + sys.getsizeof(None) - ctypes.sizeof(ctypes.c_void_p)
592596
597+ def tuple_ob_items_field(tup):
598+ assert isinstance(tup, tuple)
599+ return id(tup) + sys.getsizeof(()) - sys.getsizeof(None)
600+
593601def main():
594602 bad_type = (1, 2, 3)
595603 bad_elem = (4, 5, 6)
596604 nullelem = (7, 8, 9)
597605 bad_list = [0, 1, 2]
598606
599607 TupleObject.from_address(ob_type_field(bad_type)).ob_type = 0xded
600- TupleObject .from_address(ob_type_field (bad_elem)).ob_item1 = 0xbad
601- TupleObject .from_address(ob_type_field (nullelem)).ob_item1 = 0x0
608+ TupleItems .from_address(tuple_ob_items_field (bad_elem)).ob_item1 = 0xbad
609+ TupleItems .from_address(tuple_ob_items_field (nullelem)).ob_item1 = 0x0
602610 ListObject.from_address(ob_type_field(bad_list)).ob_item = 0x0
603611
604612 fifo = sys.argv[1]
You can’t perform that action at this time.
0 commit comments