Fix upb_MiniTable_Build not handling kUpb_MessageModifier_IsExtendable.

PiperOrigin-RevId: 449262594
pull/13171/head
Protobuf Team 3 years ago committed by Copybara-Service
parent e4c7f82664
commit a30bb1b842
  1. 3
      upb/mini_table.c
  2. 16
      upb/mini_table_test.cc

@ -747,6 +747,9 @@ static void upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr, size_t len,
} else if (kUpb_EncodedValue_MinModifier <= ch &&
ch <= kUpb_EncodedValue_MaxModifier) {
ptr = upb_MtDecoder_ParseModifier(d, ptr, ch, last_field, &msg_modifiers);
if (msg_modifiers & kUpb_MessageModifier_IsExtendable) {
d->table->ext |= kUpb_ExtMode_Extendable;
}
} else if (ch == kUpb_EncodedValue_End) {
if (!d->table) {
upb_MtDecoder_ErrorFormat(d, "Extensions cannot have oneofs.");

@ -228,3 +228,19 @@ TEST(MiniTableEnumTest, PositiveAndNegative) {
EXPECT_EQ(values.contains(i), upb_MiniTable_Enum_CheckValue(table, i)) << i;
}
}
TEST_P(MiniTableTest, Extendible) {
upb::Arena arena;
upb::MtDataEncoder e;
ASSERT_TRUE(e.StartMessage(kUpb_MessageModifier_IsExtendable));
int count = 0;
for (int i = kUpb_FieldType_Double; i < kUpb_FieldType_SInt64; i++) {
ASSERT_TRUE(e.PutField(static_cast<upb_FieldType>(i), i, 0));
count++;
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(kUpb_ExtMode_Extendable, table->ext & kUpb_ExtMode_Extendable);
}

Loading…
Cancel
Save