Check IsFrozen for internal/message.c and reflection/message.c

PiperOrigin-RevId: 627531912
pull/16622/head
Hong Shin 7 months ago committed by Copybara-Service
parent 0e223312ed
commit 5b5db6666e
  1. 1
      upb/message/internal/message.c
  2. 5
      upb/reflection/message.c

@ -23,6 +23,7 @@ const double kUpb_NaN = NAN;
bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
upb_Arena* a) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
const size_t overhead = sizeof(upb_Message_Internal);
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);

@ -65,6 +65,7 @@ upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg,
upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg,
const upb_FieldDef* f,
upb_Arena* a) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
UPB_ASSERT(upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsRepeated(f));
if (upb_FieldDef_HasPresence(f) && !upb_Message_HasFieldByDef(msg, f)) {
// We need to skip the upb_Message_GetFieldByDef() call in this case.
@ -103,6 +104,7 @@ make:
bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f,
upb_MessageValue val, upb_Arena* a) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f);
if (upb_MiniTableField_IsExtension(m_f)) {
@ -115,6 +117,7 @@ bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f,
}
void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f);
if (upb_MiniTableField_IsExtension(m_f)) {
@ -125,6 +128,7 @@ void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f) {
}
void upb_Message_ClearByDef(upb_Message* msg, const upb_MessageDef* m) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
upb_Message_Clear(msg, upb_MessageDef_MiniTable(m));
}
@ -186,6 +190,7 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
bool _upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
int depth) {
UPB_ASSERT(!upb_Message_IsFrozen(msg));
size_t iter = kUpb_Message_Begin;
const upb_FieldDef* f;
upb_MessageValue val;

Loading…
Cancel
Save