Skip to content

Commit d425214

Browse files
Auto-generate files after cl/698856552
1 parent 3d065d1 commit d425214

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -7619,19 +7619,23 @@ static upb_DecodeStatus upb_Decoder_Decode(upb_Decoder* const decoder,
76197619
return decoder->status;
76207620
}
76217621

7622+
uint16_t upb_DecodeOptions_GetEffectiveMaxDepth(uint32_t options) {
7623+
uint16_t max_depth = upb_DecodeOptions_GetMaxDepth(options);
7624+
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
7625+
}
7626+
76227627
upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
76237628
const upb_MiniTable* mt,
76247629
const upb_ExtensionRegistry* extreg, int options,
76257630
upb_Arena* arena) {
76267631
UPB_ASSERT(!upb_Message_IsFrozen(msg));
76277632
upb_Decoder decoder;
7628-
unsigned depth = (unsigned)options >> 16;
76297633

76307634
upb_EpsCopyInputStream_Init(&decoder.input, &buf, size,
76317635
options & kUpb_DecodeOption_AliasString);
76327636

76337637
decoder.extreg = extreg;
7634-
decoder.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit;
7638+
decoder.depth = upb_DecodeOptions_GetEffectiveMaxDepth(options);
76357639
decoder.end_group = DECODE_NOGROUP;
76367640
decoder.options = (uint16_t)options;
76377641
decoder.missing_required = false;
@@ -8341,19 +8345,23 @@ static upb_EncodeStatus upb_Encoder_Encode(upb_encstate* const encoder,
83418345
return encoder->status;
83428346
}
83438347

8348+
uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options) {
8349+
uint16_t max_depth = upb_EncodeOptions_GetMaxDepth(options);
8350+
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
8351+
}
8352+
83448353
static upb_EncodeStatus _upb_Encode(const upb_Message* msg,
83458354
const upb_MiniTable* l, int options,
83468355
upb_Arena* arena, char** buf, size_t* size,
83478356
bool prepend_len) {
83488357
upb_encstate e;
8349-
unsigned depth = (unsigned)options >> 16;
83508358

83518359
e.status = kUpb_EncodeStatus_Ok;
83528360
e.arena = arena;
83538361
e.buf = NULL;
83548362
e.limit = NULL;
83558363
e.ptr = NULL;
8356-
e.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit;
8364+
e.depth = upb_EncodeOptions_GetEffectiveMaxDepth(options);
83578365
e.options = options;
83588366
_upb_mapsorter_init(&e.sorter);
83598367

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

+4
Original file line numberDiff line numberDiff line change
@@ -5414,6 +5414,8 @@ UPB_INLINE uint16_t upb_DecodeOptions_GetMaxDepth(uint32_t options) {
54145414
return options >> 16;
54155415
}
54165416

5417+
uint16_t upb_DecodeOptions_GetEffectiveMaxDepth(uint32_t options);
5418+
54175419
// Enforce an upper bound on recursion depth.
54185420
UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) {
54195421
uint32_t max_depth = upb_DecodeOptions_GetMaxDepth(decode_options);
@@ -5514,6 +5516,8 @@ UPB_INLINE uint16_t upb_EncodeOptions_GetMaxDepth(uint32_t options) {
55145516
return options >> 16;
55155517
}
55165518

5519+
uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options);
5520+
55175521
// Enforce an upper bound on recursion depth.
55185522
UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) {
55195523
uint32_t max_depth = upb_EncodeOptions_GetMaxDepth(encode_options);

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -7619,19 +7619,23 @@ static upb_DecodeStatus upb_Decoder_Decode(upb_Decoder* const decoder,
76197619
return decoder->status;
76207620
}
76217621

7622+
uint16_t upb_DecodeOptions_GetEffectiveMaxDepth(uint32_t options) {
7623+
uint16_t max_depth = upb_DecodeOptions_GetMaxDepth(options);
7624+
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
7625+
}
7626+
76227627
upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
76237628
const upb_MiniTable* mt,
76247629
const upb_ExtensionRegistry* extreg, int options,
76257630
upb_Arena* arena) {
76267631
UPB_ASSERT(!upb_Message_IsFrozen(msg));
76277632
upb_Decoder decoder;
7628-
unsigned depth = (unsigned)options >> 16;
76297633

76307634
upb_EpsCopyInputStream_Init(&decoder.input, &buf, size,
76317635
options & kUpb_DecodeOption_AliasString);
76327636

76337637
decoder.extreg = extreg;
7634-
decoder.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit;
7638+
decoder.depth = upb_DecodeOptions_GetEffectiveMaxDepth(options);
76357639
decoder.end_group = DECODE_NOGROUP;
76367640
decoder.options = (uint16_t)options;
76377641
decoder.missing_required = false;
@@ -8341,19 +8345,23 @@ static upb_EncodeStatus upb_Encoder_Encode(upb_encstate* const encoder,
83418345
return encoder->status;
83428346
}
83438347

8348+
uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options) {
8349+
uint16_t max_depth = upb_EncodeOptions_GetMaxDepth(options);
8350+
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
8351+
}
8352+
83448353
static upb_EncodeStatus _upb_Encode(const upb_Message* msg,
83458354
const upb_MiniTable* l, int options,
83468355
upb_Arena* arena, char** buf, size_t* size,
83478356
bool prepend_len) {
83488357
upb_encstate e;
8349-
unsigned depth = (unsigned)options >> 16;
83508358

83518359
e.status = kUpb_EncodeStatus_Ok;
83528360
e.arena = arena;
83538361
e.buf = NULL;
83548362
e.limit = NULL;
83558363
e.ptr = NULL;
8356-
e.depth = depth ? depth : kUpb_WireFormat_DefaultDepthLimit;
8364+
e.depth = upb_EncodeOptions_GetEffectiveMaxDepth(options);
83578365
e.options = options;
83588366
_upb_mapsorter_init(&e.sorter);
83598367

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

+4
Original file line numberDiff line numberDiff line change
@@ -5416,6 +5416,8 @@ UPB_INLINE uint16_t upb_DecodeOptions_GetMaxDepth(uint32_t options) {
54165416
return options >> 16;
54175417
}
54185418

5419+
uint16_t upb_DecodeOptions_GetEffectiveMaxDepth(uint32_t options);
5420+
54195421
// Enforce an upper bound on recursion depth.
54205422
UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) {
54215423
uint32_t max_depth = upb_DecodeOptions_GetMaxDepth(decode_options);
@@ -5516,6 +5518,8 @@ UPB_INLINE uint16_t upb_EncodeOptions_GetMaxDepth(uint32_t options) {
55165518
return options >> 16;
55175519
}
55185520

5521+
uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options);
5522+
55195523
// Enforce an upper bound on recursion depth.
55205524
UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) {
55215525
uint32_t max_depth = upb_EncodeOptions_GetMaxDepth(encode_options);

0 commit comments

Comments
 (0)