Commit 47b92d31 authored by Matthew Maurer's avatar Matthew Maurer

Fix uninitialized members of ListBuilder

Adding a `KJ_DASSERT` in the `setListPointer` logic flagged
non-word-multiple data sections in `INLINE_COMPOSITE` lists, which
should be impossible. This traced back to uninitialized member variables
in `ListBuilder` in the case that it was created from a null pointer.
parent e1d2d0a7
...@@ -1609,6 +1609,7 @@ struct WireHelpers { ...@@ -1609,6 +1609,7 @@ struct WireHelpers {
return { segment, ptr }; return { segment, ptr };
} else { } else {
// List of structs. // List of structs.
KJ_DASSERT(value.structDataSize % BITS_PER_WORD == 0 * BITS);
word* ptr = allocate(ref, segment, capTable, totalSize + POINTER_SIZE_IN_WORDS, word* ptr = allocate(ref, segment, capTable, totalSize + POINTER_SIZE_IN_WORDS,
WirePointer::LIST, orphanArena); WirePointer::LIST, orphanArena);
ref->listRef.setInlineComposite(totalSize); ref->listRef.setInlineComposite(totalSize);
......
...@@ -643,7 +643,8 @@ class ListBuilder: public kj::DisallowConstCopy { ...@@ -643,7 +643,8 @@ class ListBuilder: public kj::DisallowConstCopy {
public: public:
inline explicit ListBuilder(ElementSize elementSize) inline explicit ListBuilder(ElementSize elementSize)
: segment(nullptr), capTable(nullptr), ptr(nullptr), elementCount(0 * ELEMENTS), : segment(nullptr), capTable(nullptr), ptr(nullptr), elementCount(0 * ELEMENTS),
step(0 * BITS / ELEMENTS), elementSize(elementSize) {} step(0 * BITS / ELEMENTS), elementSize(elementSize), structDataSize(0 * BITS),
structPointerCount(0 * POINTERS) {}
MSVC_DEFAULT_ASSIGNMENT_WORKAROUND(, ListBuilder) MSVC_DEFAULT_ASSIGNMENT_WORKAROUND(, ListBuilder)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment