Allow users to force eager parsing via CodedInputStream::ForceEagerParsing().

PiperOrigin-RevId: 579989063
pull/14651/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent f247630a10
commit d63a145c7e
  1. 2
      src/google/protobuf/extension_set_heavy.cc
  2. 1
      src/google/protobuf/extension_set_unittest.cc
  3. 6
      src/google/protobuf/io/coded_stream.h
  4. 2
      src/google/protobuf/message_lite.cc

@ -12,6 +12,8 @@
// Contains methods defined in extension_set.h which cannot be part of the
// lite library because they use descriptors or reflection.
#include <cstddef>
#include <cstdint>
#include <vector>
#include "absl/log/absl_check.h"

@ -11,6 +11,7 @@
#include "google/protobuf/extension_set.h"
#include <cstdint>
#include <string>
#include "google/protobuf/descriptor.pb.h"

@ -91,6 +91,7 @@
#include <atomic>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#include <string>
@ -522,6 +523,9 @@ class PROTOBUF_EXPORT CodedInputStream {
// See EnableAliasing().
bool aliasing_enabled_;
// If true, set eager parsing mode to override lazy fields.
bool force_eager_parsing_;
// Limits
Limit current_limit_; // if position = -1, no limit is applied
@ -1553,6 +1557,7 @@ inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)
last_tag_(0),
legitimate_message_end_(false),
aliasing_enabled_(false),
force_eager_parsing_(false),
current_limit_(std::numeric_limits<int32_t>::max()),
buffer_size_after_limit_(0),
total_bytes_limit_(kDefaultTotalBytesLimit),
@ -1573,6 +1578,7 @@ inline CodedInputStream::CodedInputStream(const uint8_t* buffer, int size)
last_tag_(0),
legitimate_message_end_(false),
aliasing_enabled_(false),
force_eager_parsing_(false),
current_limit_(size),
buffer_size_after_limit_(0),
total_bytes_limit_(kDefaultTotalBytesLimit),

@ -251,7 +251,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input,
if (PROTOBUF_PREDICT_FALSE(!ptr)) return false;
ctx.BackUp(ptr);
if (!ctx.EndedAtEndOfStream()) {
ABSL_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
ABSL_DCHECK_NE(ctx.LastTag(), 1u); // We can't end on a pushed limit.
if (ctx.IsExceedingLimit(ptr)) return false;
input->SetLastTag(ctx.LastTag());
} else {

Loading…
Cancel
Save