mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-14 17:43:53 +00:00
Fix leak in var arg handling
When using the mixed position + vararg path, pybind over inc_ref's the vararg positions. Printing the ref_count() of `item` before and after this change you see: Before change: ``` refcount of item before assign 3 refcount of item after assign 5 ``` After change ``` refcount of item before assign 3 refcount of item after assign 4 ```
This commit is contained in:
parent
48e1f9aadc
commit
03874e3738
@ -581,7 +581,7 @@ protected:
|
|||||||
extra_args = tuple(args_size);
|
extra_args = tuple(args_size);
|
||||||
for (size_t i = 0; i < args_size; ++i) {
|
for (size_t i = 0; i < args_size; ++i) {
|
||||||
handle item = PyTuple_GET_ITEM(args_in, args_copied + i);
|
handle item = PyTuple_GET_ITEM(args_in, args_copied + i);
|
||||||
extra_args[i] = item.inc_ref().ptr();
|
extra_args[i] = reinterpret_borrow<object>(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
call.args.push_back(extra_args);
|
call.args.push_back(extra_args);
|
||||||
|
Loading…
Reference in New Issue
Block a user