Skip to content

Commit 8d886cf

Browse files
Auto-generate files after cl/855944266
1 parent 4029df0 commit 8d886cf

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

php/ext/google/protobuf/php-upb.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16499,17 +16499,32 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
1649916499
// Parse map entry.
1650016500
memset(&ent, 0, sizeof(ent));
1650116501

16502-
if (entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
16502+
bool value_is_message =
16503+
entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
1650316504
kUpb_FieldType_Message ||
1650416505
entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
16505-
kUpb_FieldType_Group) {
16506+
kUpb_FieldType_Group;
16507+
const upb_MiniTable* sub_table =
16508+
value_is_message
16509+
? upb_MiniTable_GetSubMessageTable(&entry->UPB_PRIVATE(fields)[1])
16510+
: NULL;
16511+
upb_Message* sub_msg = NULL;
16512+
16513+
if (sub_table) {
1650616514
// Create proactively to handle the case where it doesn't appear.
16507-
upb_Message* msg;
16508-
_upb_Decoder_NewSubMessage(d, &entry->UPB_PRIVATE(fields)[1], &msg);
16509-
ent.v.val = upb_value_ptr(msg);
16515+
_upb_Decoder_NewSubMessage(d, &entry->UPB_PRIVATE(fields)[1], &sub_msg);
16516+
ent.v.val = upb_value_ptr(sub_msg);
1651016517
}
1651116518

1651216519
ptr = _upb_Decoder_DecodeSubMessage(d, ptr, &ent.message, field, val->size);
16520+
16521+
if (sub_msg && sub_table->UPB_PRIVATE(required_count)) {
16522+
// If the map entry did not contain a value on the wire, `sub_msg` is an
16523+
// empty message; we must check if it is missing any required fields. If the
16524+
// value was present, this check is redundant but harmless.
16525+
_upb_Decoder_CheckRequired(d, ptr, sub_msg, sub_table);
16526+
}
16527+
1651316528
if (upb_Message_HasUnknown(&ent.message)) {
1651416529
_upb_Decoder_AddMapEntryUnknown(d, msg, field, &ent.message, entry);
1651516530
} else {

ruby/ext/google/protobuf_c/ruby-upb.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16058,17 +16058,32 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
1605816058
// Parse map entry.
1605916059
memset(&ent, 0, sizeof(ent));
1606016060

16061-
if (entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
16061+
bool value_is_message =
16062+
entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
1606216063
kUpb_FieldType_Message ||
1606316064
entry->UPB_PRIVATE(fields)[1].UPB_PRIVATE(descriptortype) ==
16064-
kUpb_FieldType_Group) {
16065+
kUpb_FieldType_Group;
16066+
const upb_MiniTable* sub_table =
16067+
value_is_message
16068+
? upb_MiniTable_GetSubMessageTable(&entry->UPB_PRIVATE(fields)[1])
16069+
: NULL;
16070+
upb_Message* sub_msg = NULL;
16071+
16072+
if (sub_table) {
1606516073
// Create proactively to handle the case where it doesn't appear.
16066-
upb_Message* msg;
16067-
_upb_Decoder_NewSubMessage(d, &entry->UPB_PRIVATE(fields)[1], &msg);
16068-
ent.v.val = upb_value_ptr(msg);
16074+
_upb_Decoder_NewSubMessage(d, &entry->UPB_PRIVATE(fields)[1], &sub_msg);
16075+
ent.v.val = upb_value_ptr(sub_msg);
1606916076
}
1607016077

1607116078
ptr = _upb_Decoder_DecodeSubMessage(d, ptr, &ent.message, field, val->size);
16079+
16080+
if (sub_msg && sub_table->UPB_PRIVATE(required_count)) {
16081+
// If the map entry did not contain a value on the wire, `sub_msg` is an
16082+
// empty message; we must check if it is missing any required fields. If the
16083+
// value was present, this check is redundant but harmless.
16084+
_upb_Decoder_CheckRequired(d, ptr, sub_msg, sub_table);
16085+
}
16086+
1607216087
if (upb_Message_HasUnknown(&ent.message)) {
1607316088
_upb_Decoder_AddMapEntryUnknown(d, msg, field, &ent.message, entry);
1607416089
} else {

0 commit comments

Comments
 (0)