From aa68739fa716d53bc278484410b78070bdf579b0 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 18 Jan 2023 10:46:16 -0800 Subject: [PATCH] Fixed a bug with field numbers >255 in a oneof. The compiler should not assert-fail in this case, it should merely decline to emit a fast parser for that field. PiperOrigin-RevId: 502919928 --- upbc/protoc-gen-upb.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/upbc/protoc-gen-upb.cc b/upbc/protoc-gen-upb.cc index 4e0e67a96f..5a8308a373 100644 --- a/upbc/protoc-gen-upb.cc +++ b/upbc/protoc-gen-upb.cc @@ -1107,8 +1107,7 @@ bool TryFillTableEntry(const DefPoolPair& pools, upb::FieldDefPtr field, } if (field.real_containing_oneof()) { uint64_t case_offset = ~mt_f->presence; - if (case_offset > 0xffff) return false; - assert(field.number() < 256); + if (case_offset > 0xffff || field.number() > 0xff) return false; data |= field.number() << 24; data |= case_offset << 32; } else {