mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-12 11:47:50 +00:00
Fix actual undefined behavior exposed by previous changes.
It turns out the previous commit message is incorrect, the `inst` pointer is actually dereferenced, in the `value_and_holder` ctor here:
f3e0602802/include/pybind11/detail/type_caster_base.h (L262-L263)
```
259 // Main constructor for a found value/holder:
260 value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
261 : inst{i}, index{index}, type{type},
262 vh{inst->simple_layout ? inst->simple_value_holder
263 : &inst->nonsimple.values_and_holders[vpos]} {}
```
This commit is contained in:
parent
cf5958d516
commit
c89561f77a
@ -349,12 +349,16 @@ public:
|
||||
const type_vec *types = nullptr;
|
||||
value_and_holder curr;
|
||||
friend struct values_and_holders;
|
||||
iterator(instance *inst, const type_vec *tinfo)
|
||||
: inst{inst}, types{tinfo},
|
||||
curr(inst /* instance */,
|
||||
types->empty() ? nullptr : (*types)[0] /* type info */,
|
||||
0, /* vpos: (non-simple types only): the first vptr comes first */
|
||||
0 /* index */) {}
|
||||
iterator(instance *inst, const type_vec *tinfo) : inst{inst}, types{tinfo} {
|
||||
if (inst != nullptr) {
|
||||
assert(!types->empty());
|
||||
curr = value_and_holder(
|
||||
inst /* instance */,
|
||||
(*types)[0] /* type info */,
|
||||
0, /* vpos: (non-simple types only): the first vptr comes first */
|
||||
0 /* index */);
|
||||
}
|
||||
}
|
||||
// Past-the-end iterator:
|
||||
explicit iterator(size_t end) : curr(end) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user