Skip to content

Commit

Permalink
Fix merge issue: Update upb dep to commit fixing ruby flake. Also fix…
Browse files Browse the repository at this point in the history
…es bad amalgamation update from bad merge.
  • Loading branch information
zhangskz committed Feb 10, 2023
1 parent 8593674 commit 6a00a20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
27 changes: 20 additions & 7 deletions php/ext/google/protobuf/php-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7145,13 +7145,26 @@ bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
UPB_ASSERT((uintptr_t)table->fields <= (uintptr_t)field &&
(uintptr_t)field <
(uintptr_t)(table->fields + table->field_count));
// TODO: check these type invariants at runtime and return error to the
// caller if they are violated, instead of using an assert.
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message ||
field->descriptortype == kUpb_FieldType_Group);
if (sub->ext & kUpb_ExtMode_IsMapEntry) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message);
field->mode = (field->mode & ~kUpb_FieldMode_Mask) | kUpb_FieldMode_Map;
UPB_ASSERT(sub);

const bool sub_is_map = sub->ext & kUpb_ExtMode_IsMapEntry;

switch (field->descriptortype) {
case kUpb_FieldType_Message:
if (sub_is_map) {
const bool table_is_map = table->ext & kUpb_ExtMode_IsMapEntry;
if (UPB_UNLIKELY(table_is_map)) return false;

field->mode = (field->mode & ~kUpb_FieldMode_Mask) | kUpb_FieldMode_Map;
}
break;

case kUpb_FieldType_Group:
if (UPB_UNLIKELY(sub_is_map)) return false;
break;

default:
return false;
}

upb_MiniTableSub* table_sub = (void*)&table->subs[field->submsg_index];
Expand Down
4 changes: 2 additions & 2 deletions protobuf_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def protobuf_deps():
_github_archive(
name = "upb",
repo = "https://github.com/protocolbuffers/upb",
commit = "4bea50c834fd714238c700bedecfd4b75bc833f3",
sha256 = "5664903676dd9b784250e0a6502f712057100e362d4bbdbc0ba3ab1f3cdb7daf",
commit = "662497f1d3dcced2bba1620cea9aae8b484bd3cd",
sha256 = "57c87ca4145d2cbc162a6c613b114b9325b577f4f6525bd78747a34b3d03627c",
patches = ["@com_google_protobuf//build_defs:upb.patch"],
)
27 changes: 20 additions & 7 deletions ruby/ext/google/protobuf_c/ruby-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6782,13 +6782,26 @@ bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
UPB_ASSERT((uintptr_t)table->fields <= (uintptr_t)field &&
(uintptr_t)field <
(uintptr_t)(table->fields + table->field_count));
// TODO: check these type invariants at runtime and return error to the
// caller if they are violated, instead of using an assert.
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message ||
field->descriptortype == kUpb_FieldType_Group);
if (sub->ext & kUpb_ExtMode_IsMapEntry) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message);
field->mode = (field->mode & ~kUpb_FieldMode_Mask) | kUpb_FieldMode_Map;
UPB_ASSERT(sub);

const bool sub_is_map = sub->ext & kUpb_ExtMode_IsMapEntry;

switch (field->descriptortype) {
case kUpb_FieldType_Message:
if (sub_is_map) {
const bool table_is_map = table->ext & kUpb_ExtMode_IsMapEntry;
if (UPB_UNLIKELY(table_is_map)) return false;

field->mode = (field->mode & ~kUpb_FieldMode_Mask) | kUpb_FieldMode_Map;
}
break;

case kUpb_FieldType_Group:
if (UPB_UNLIKELY(sub_is_map)) return false;
break;

default:
return false;
}

upb_MiniTableSub* table_sub = (void*)&table->subs[field->submsg_index];
Expand Down

0 comments on commit 6a00a20

Please sign in to comment.