Skip to content

Commit 38f408f

Browse files
ax3lwjakob
authored andcommitted
value_and_holder: uninit members (#1660)
fix some uninitialized members in `value_and_holder` for some of the constructurs. Found with coverity in a downstream project.
1 parent 868d94f commit 38f408f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/pybind11/cast.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ PYBIND11_NOINLINE inline handle get_type_handle(const std::type_info &tp, bool t
204204
}
205205

206206
struct value_and_holder {
207-
instance *inst;
208-
size_t index;
209-
const detail::type_info *type;
210-
void **vh;
207+
instance *inst = nullptr;
208+
size_t index = 0u;
209+
const detail::type_info *type = nullptr;
210+
void **vh = nullptr;
211211

212212
// Main constructor for a found value/holder:
213213
value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index) :
@@ -216,7 +216,7 @@ struct value_and_holder {
216216
{}
217217

218218
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
219-
value_and_holder() : inst{nullptr} {}
219+
value_and_holder() {}
220220

221221
// Used for past-the-end iterator
222222
value_and_holder(size_t index) : index{index} {}
@@ -270,8 +270,8 @@ struct values_and_holders {
270270

271271
struct iterator {
272272
private:
273-
instance *inst;
274-
const type_vec *types;
273+
instance *inst = nullptr;
274+
const type_vec *types = nullptr;
275275
value_and_holder curr;
276276
friend struct values_and_holders;
277277
iterator(instance *inst, const type_vec *tinfo)

0 commit comments

Comments
 (0)