mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-05 20:54:53 +00:00
Fix invalid memory access in vector insert method
The stl_bind.h wrapper for `Vector.insert` neglected to do a bounds check.
This commit is contained in:
committed by
Jason Rhinelander
parent
6a0f6c40cd
commit
eee4f4fc7e
@@ -145,6 +145,8 @@ void vector_modifiers(enable_if_t<std::is_copy_constructible<typename Vector::va
|
||||
|
||||
cl.def("insert",
|
||||
[](Vector &v, SizeType i, const T &x) {
|
||||
if (i > v.size())
|
||||
throw index_error();
|
||||
v.insert(v.begin() + (DiffType) i, x);
|
||||
},
|
||||
arg("i") , arg("x"),
|
||||
|
||||
Reference in New Issue
Block a user