mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
upb: Adds a new error code kUpb_ErrorCode_MaxDepthExceeded.
PiperOrigin-RevId: 923465700
This commit is contained in:
parent
b387c2d322
commit
8ceca4cb58
5 changed files with 25 additions and 20 deletions
|
|
@ -21,9 +21,9 @@ use sys::mini_table::mini_table::RawMiniTable;
|
|||
pub enum EncodeStatus {
|
||||
Ok = 0,
|
||||
OutOfMemory = 1,
|
||||
MaxDepthExceeded = 2,
|
||||
MissingRequired = 3,
|
||||
MaxSizeExceeded = 4,
|
||||
MaxDepthExceeded = 3,
|
||||
MissingRequired = 10,
|
||||
MaxSizeExceeded = 11,
|
||||
}
|
||||
// LINT.ThenChange()
|
||||
|
||||
|
|
@ -35,9 +35,9 @@ pub enum DecodeStatus {
|
|||
Ok = 0,
|
||||
OutOfMemory = 1,
|
||||
Malformed = 2,
|
||||
BadUtf8 = 3,
|
||||
MaxDepthExceeded = 4,
|
||||
MissingRequired = 5,
|
||||
MaxDepthExceeded = 3,
|
||||
BadUtf8 = 10,
|
||||
MissingRequired = 11,
|
||||
}
|
||||
// LINT.ThenChange()
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ typedef enum {
|
|||
kUpb_ErrorCode_Ok = 0,
|
||||
kUpb_ErrorCode_OutOfMemory = 1,
|
||||
kUpb_ErrorCode_Malformed = 2,
|
||||
kUpb_ErrorCode_MaxDepthExceeded = 3,
|
||||
} upb_ErrorCode;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -490,8 +490,7 @@ static void upb_Message_ConvertInternal(upb_Converter* c, upb_Message* dst,
|
|||
int depth) {
|
||||
UPB_ASSERT(dst != NULL);
|
||||
if (--depth == 0) {
|
||||
// TODO:b/494593478 - Add a new error code for max depth exceeded.
|
||||
upb_ErrorHandler_ThrowError(&c->err, kUpb_ErrorCode_Malformed);
|
||||
upb_ErrorHandler_ThrowError(&c->err, kUpb_ErrorCode_MaxDepthExceeded);
|
||||
}
|
||||
|
||||
const upb_MiniTableField* dst_f = NULL;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "upb/base/error_handler.h"
|
||||
#include "upb/mem/arena.h"
|
||||
#include "upb/message/message.h"
|
||||
#include "upb/mini_table/extension_registry.h"
|
||||
|
|
@ -83,16 +84,19 @@ UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) {
|
|||
|
||||
// LINT.IfChange
|
||||
typedef enum {
|
||||
kUpb_DecodeStatus_Ok = 0,
|
||||
kUpb_DecodeStatus_OutOfMemory = 1, // Arena alloc failed
|
||||
kUpb_DecodeStatus_Malformed = 2, // Wire format was corrupt
|
||||
kUpb_DecodeStatus_BadUtf8 = 3, // String field had bad UTF-8
|
||||
kUpb_DecodeStatus_Ok = kUpb_ErrorCode_Ok,
|
||||
kUpb_DecodeStatus_OutOfMemory =
|
||||
kUpb_ErrorCode_OutOfMemory, // Arena alloc failed
|
||||
kUpb_DecodeStatus_Malformed =
|
||||
kUpb_ErrorCode_Malformed, // Wire format was corrupt
|
||||
kUpb_DecodeStatus_MaxDepthExceeded =
|
||||
4, // Exceeded upb_DecodeOptions_MaxDepth
|
||||
kUpb_ErrorCode_MaxDepthExceeded, // Exceeded upb_DecodeOptions_MaxDepth
|
||||
|
||||
kUpb_DecodeStatus_BadUtf8 = 10, // String field had bad UTF-8
|
||||
|
||||
// kUpb_DecodeOption_CheckRequired failed (see above), but the parse otherwise
|
||||
// succeeded.
|
||||
kUpb_DecodeStatus_MissingRequired = 5,
|
||||
kUpb_DecodeStatus_MissingRequired = 11,
|
||||
} upb_DecodeStatus;
|
||||
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/wire/wire.rs:decode_status)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "upb/base/error_handler.h"
|
||||
#include "upb/mem/arena.h"
|
||||
#include "upb/message/message.h"
|
||||
#include "upb/mini_table/message.h"
|
||||
|
|
@ -43,16 +44,16 @@ enum {
|
|||
|
||||
// LINT.IfChange
|
||||
typedef enum {
|
||||
kUpb_EncodeStatus_Ok = 0,
|
||||
kUpb_EncodeStatus_OutOfMemory = 1, // Arena alloc failed
|
||||
kUpb_EncodeStatus_MaxDepthExceeded = 2,
|
||||
|
||||
kUpb_EncodeStatus_Ok = kUpb_ErrorCode_Ok,
|
||||
kUpb_EncodeStatus_OutOfMemory =
|
||||
kUpb_ErrorCode_OutOfMemory, // Arena alloc failed
|
||||
// One or more required fields are missing. Only returned if
|
||||
// kUpb_EncodeOption_CheckRequired is set.
|
||||
kUpb_EncodeStatus_MissingRequired = 3,
|
||||
kUpb_EncodeStatus_MaxDepthExceeded = kUpb_ErrorCode_MaxDepthExceeded,
|
||||
|
||||
kUpb_EncodeStatus_MissingRequired = 10,
|
||||
// The message is larger than protobuf's 2GB size limit.
|
||||
kUpb_EncodeStatus_MaxSizeExceeded = 4,
|
||||
kUpb_EncodeStatus_MaxSizeExceeded = 11,
|
||||
} upb_EncodeStatus;
|
||||
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/wire/wire.rs:encode_status)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue