diff options
Diffstat (limited to 'src/google/protobuf/wire_format_lite_inl.h')
-rw-r--r-- | src/google/protobuf/wire_format_lite_inl.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index feb22540..129fc63f 100644 --- a/src/google/protobuf/wire_format_lite_inl.h +++ b/src/google/protobuf/wire_format_lite_inl.h @@ -47,6 +47,7 @@ #include <google/protobuf/repeated_field.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/arenastring.h> namespace google { @@ -426,6 +427,7 @@ bool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input, } + inline bool WireFormatLite::ReadGroup(int field_number, io::CodedInputStream* input, MessageLite* value) { @@ -442,15 +444,12 @@ inline bool WireFormatLite::ReadMessage(io::CodedInputStream* input, MessageLite* value) { uint32 length; if (!input->ReadVarint32(&length)) return false; - if (!input->IncrementRecursionDepth()) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - if (!value->MergePartialFromCodedStream(input)) return false; + std::pair<io::CodedInputStream::Limit, int> p = + input->IncrementRecursionDepthAndPushLimit(length); + if (p.second < 0 || !value->MergePartialFromCodedStream(input)) return false; // Make sure that parsing stopped when the limit was hit, not at an endgroup // tag. - if (!input->ConsumedEntireMessage()) return false; - input->PopLimit(limit); - input->DecrementRecursionDepth(); - return true; + return input->DecrementRecursionDepthAndPopLimit(p.first); } // We name the template parameter something long and extremely unlikely to occur @@ -483,17 +482,14 @@ inline bool WireFormatLite::ReadMessageNoVirtual( io::CodedInputStream* input, MessageType_WorkAroundCppLookupDefect* value) { uint32 length; if (!input->ReadVarint32(&length)) return false; - if (!input->IncrementRecursionDepth()) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - if (!value-> + std::pair<io::CodedInputStream::Limit, int> p = + input->IncrementRecursionDepthAndPushLimit(length); + if (p.second < 0 || !value-> MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input)) return false; // Make sure that parsing stopped when the limit was hit, not at an endgroup // tag. - if (!input->ConsumedEntireMessage()) return false; - input->PopLimit(limit); - input->DecrementRecursionDepth(); - return true; + return input->DecrementRecursionDepthAndPopLimit(p.first); } // =================================================================== |