diff options
author | Colin Cross <ccross@android.com> | 2021-02-08 14:49:18 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2021-02-09 18:33:02 +0000 |
commit | a7e18248e5692497df0bcb7b2dca5edcdee87d95 (patch) | |
tree | f252e377ef0018c4d2e2438f7e18753686d28d04 | |
parent | 21a9fa709b5f3ca3ec2999cf826d77c436bf2389 (diff) | |
download | protobuf-a7e18248e5692497df0bcb7b2dca5edcdee87d95.tar.gz |
Backport null pointer check from upstream
Backport [1] from upstream to avoid a null pointer dereference.
[1] https://github.com/protocolbuffers/protobuf/commit/32e5deb1ac76feb4f187371c2a7f76c9009b1eff#diff-9ac2dd60c731243464677560177e2552aaf5fb4301333d475ed039343f36d63f
Bug: 179161711
Test: mmma external/protobuf
Change-Id: I3b0c272317675956043c92adbf99ed3042f222d6
Merged-In: I3b0c272317675956043c92adbf99ed3042f222d6
(cherry picked from commit 2cc88998253443703a2c16d6f24775689eea49d8)
-rw-r--r-- | src/google/protobuf/util/internal/protostream_objectsource.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 252184df0..f632064cc 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -539,6 +539,11 @@ Status ProtoStreamObjectSource::RenderStruct(const ProtoStreamObjectSource* os, ow->StartObject(field_name); while (tag != 0) { field = os->FindAndVerifyField(type, tag); + if (field == nullptr) { + WireFormat::SkipField(os->stream_, tag, nullptr); + tag = os->stream_->ReadTag(); + continue; + } // google.protobuf.Struct has only one field that is a map. Hence we use // RenderMap to render that field. if (os->IsMap(*field)) { |