Commit cc4611d3 authored by David Renshaw's avatar David Renshaw

fix isCanonical on INLINE_COMPOSITE lists with zero-sized structs

parent 8d53497a
......@@ -185,6 +185,23 @@ KJ_TEST("isCanonical rejects unused trailing words") {
KJ_ASSERT(!message.isCanonical());
}
KJ_TEST("isCanonical accepts empty inline composite list of zero-sized structs") {
AlignedData<3> segment = {{
// Struct pointer, pointer in next word
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
// List pointer, inline composite, zero words long
0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
// Tag word
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}};
kj::ArrayPtr<const word> segments[1] = {kj::arrayPtr(segment.words, 3)};
SegmentArrayMessageReader message(kj::arrayPtr(segments, 1));
KJ_ASSERT(message.isCanonical());
}
KJ_TEST("upgraded lists can be canonicalized") {
AlignedData<7> upgradedList = {{
//Struct pointer, data immediately follows, 4 pointer fields, no data
......
......@@ -2965,6 +2965,9 @@ bool ListReader::isCanonical(const word **readHead) {
}
auto structSize = (this->structDataSize / BITS_PER_WORD) +
(this->structPointerCount * WORDS_PER_POINTER);
if (structSize == 0 * WORDS) {
return true;
}
auto listEnd = *readHead + (this->elementCount / ELEMENTS * structSize) / WORDS;
auto pointerHead = listEnd;
bool listDataTrunc = false;
......
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