Skip to content

Commit 8566dbf

Browse files
committed
value_and_holder: uninit members
fix some uninitialized members in `value_and_holder` for some of the constructurs. Found with coverity in a downstream project.
1 parent 085a294 commit 8566dbf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

include/pybind11/cast.h

Lines changed: 5 additions & 5 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} {}

0 commit comments

Comments
 (0)