mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Internal change
PiperOrigin-RevId: 939972433
This commit is contained in:
parent
6fc9d438b7
commit
142d3928b2
5 changed files with 10 additions and 14 deletions
|
|
@ -27,7 +27,6 @@ pub enum ExtensionRegistryStatus {
|
|||
Ok = 0,
|
||||
DuplicateEntry = 1,
|
||||
OutOfMemory = 2,
|
||||
InvalidExtension = 3,
|
||||
}
|
||||
// LINT.ThenChange(//depot/google3/third_party/upb/upb/mini_table/extension_registry.h)
|
||||
|
||||
|
|
|
|||
|
|
@ -888,9 +888,15 @@ static const char* upb_MtDecoder_DoBuildMiniTableExtension(
|
|||
if (!ret || count != 1) return NULL;
|
||||
|
||||
upb_MiniTableField* f = &ext->UPB_PRIVATE(field);
|
||||
uint32_t fieldnum = upb_MiniTableField_Number(f);
|
||||
|
||||
if (upb_MiniTable_FindFieldByNumber(extendee, upb_MiniTableField_Number(f)) !=
|
||||
NULL) {
|
||||
const uint32_t kMaxFieldNumber = (1 << 29) - 1;
|
||||
if (fieldnum == 0 ||
|
||||
(fieldnum > kMaxFieldNumber && !upb_MiniTable_IsMessageSet(extendee))) {
|
||||
upb_MdDecoder_ErrorJmp(&decoder->base, "Invalid extension field number");
|
||||
}
|
||||
|
||||
if (upb_MiniTable_FindFieldByNumber(extendee, fieldnum) != NULL) {
|
||||
upb_MdDecoder_ErrorJmp(&decoder->base,
|
||||
"Extension overlaps with a known field");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "upb/hash/ext_table.h"
|
||||
#include "upb/mem/arena.h"
|
||||
#include "upb/mini_table/extension.h"
|
||||
#include "upb/mini_table/internal/message.h"
|
||||
#include "upb/mini_table/message.h"
|
||||
|
||||
// Must be last.
|
||||
|
|
@ -42,14 +41,6 @@ UPB_API upb_ExtensionRegistryStatus upb_ExtensionRegistry_Add(
|
|||
uint32_t fieldnum = upb_MiniTableExtension_Number(e);
|
||||
const upb_MiniTable* extendee = upb_MiniTableExtension_Extendee(e);
|
||||
|
||||
const uint32_t kMaxFieldNumber = (1 << 29) - 1;
|
||||
if (fieldnum == 0 ||
|
||||
(fieldnum > kMaxFieldNumber && !upb_MiniTable_IsMessageSet(extendee))) {
|
||||
return kUpb_ExtensionRegistryStatus_InvalidExtension;
|
||||
}
|
||||
|
||||
UPB_ASSERT(upb_MiniTable_FindFieldByNumber(extendee, fieldnum) == NULL);
|
||||
|
||||
if (upb_exttable_lookup(&r->exts, extendee, fieldnum) != NULL) {
|
||||
return kUpb_ExtensionRegistryStatus_DuplicateEntry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ typedef enum {
|
|||
kUpb_ExtensionRegistryStatus_Ok = 0,
|
||||
kUpb_ExtensionRegistryStatus_DuplicateEntry = 1,
|
||||
kUpb_ExtensionRegistryStatus_OutOfMemory = 2,
|
||||
kUpb_ExtensionRegistryStatus_InvalidExtension = 3,
|
||||
} upb_ExtensionRegistryStatus;
|
||||
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/mini_table/extension_registry.rs)
|
||||
|
||||
|
|
|
|||
|
|
@ -137,8 +137,9 @@ void Builder::BuildExtensions(upb_ExtensionRegistry** exts) {
|
|||
if (upb_ExtensionRegistry_Lookup(*exts, ext->UPB_PRIVATE(extendee),
|
||||
upb_MiniTableExtension_Number(ext)))
|
||||
continue;
|
||||
upb_ExtensionRegistry_AddArray(
|
||||
auto status = upb_ExtensionRegistry_AddArray(
|
||||
*exts, const_cast<const upb_MiniTableExtension**>(&ext), 1);
|
||||
UPB_ASSERT(status == kUpb_ExtensionRegistryStatus_Ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue