Skip to content

Commit f664f22

Browse files
committed
Avoid ob_size access in nanobind patch
1 parent 7bd13fd commit f664f22

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

graalpython/lib-graalpython/patches/nanobind/nanobind.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,27 @@ index c49b7bb..3a5be09 100644
941941
# if PY_VERSION_HEX < 0x030A0000
942942
# define NB_TYPE_GET_SLOT_IMPL 1 // Custom implementation of nb::type_get_slot
943943
# else
944+
diff --git a/nanobind/include/nanobind/nb_types.h b/nanobind/include/nanobind/nb_types.h
945+
index b83a651..de16f03 100644
946+
--- a/nanobind/include/nanobind/nb_types.h
947+
+++ b/nanobind/include/nanobind/nb_types.h
948+
@@ -877,14 +877,14 @@ inline detail::fast_iterator tuple::begin() const {
949+
}
950+
inline detail::fast_iterator tuple::end() const {
951+
PyTupleObject *v = (PyTupleObject *) m_ptr;
952+
- return PySequence_Fast_ITEMS((PyObject*)v) + v->ob_base.ob_size;
953+
+ return PySequence_Fast_ITEMS((PyObject*)v) + Py_SIZE(v);
954+
}
955+
inline detail::fast_iterator list::begin() const {
956+
return PySequence_Fast_ITEMS((PyObject*)((PyListObject *) m_ptr));
957+
}
958+
inline detail::fast_iterator list::end() const {
959+
PyListObject *v = (PyListObject *) m_ptr;
960+
- return PySequence_Fast_ITEMS((PyObject*)v) + v->ob_base.ob_size;
961+
+ return PySequence_Fast_ITEMS((PyObject*)v) + Py_SIZE(v);
962+
}
963+
#endif
964+
944965
diff --git a/nanobind/include/nanobind/stl/detail/chrono.h b/nanobind/include/nanobind/stl/detail/chrono.h
945966
index 39bd5d9..6e9efb0 100644
946967
--- a/nanobind/include/nanobind/stl/detail/chrono.h

0 commit comments

Comments
 (0)