aboutsummaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
diff options
context:
space:
mode:
authorBrian Duff <bduff@google.com>2013-10-09 12:23:16 -0700
committerBrian Duff <bduff@google.com>2013-10-14 23:14:58 -0700
commite03e9f4b5774c0ffe04140d83bbdb532863b1720 (patch)
tree33912f4d1966adb1bd4c9813dbc1c2276b1ac49d /src/google/protobuf/compiler/javanano/javanano_enum_field.cc
parent39cee9f1f5cd513a53ac5100eb208ed431f99af0 (diff)
downloadexternal_protobuf-e03e9f4b5774c0ffe04140d83bbdb532863b1720.zip
external_protobuf-e03e9f4b5774c0ffe04140d83bbdb532863b1720.tar.gz
external_protobuf-e03e9f4b5774c0ffe04140d83bbdb532863b1720.tar.bz2
Protect against null repeated fields.
There's no distinction between a repeated field being null and being empty. In both cases, nothing is sent on the wire. Clients might for whatever reason inadvertently set a repeated field to null, so protect against that and treat it just as if the field was empty. Change-Id: Ic3846f7f2189d6cfff6f8ef3ca217daecc3c8be7
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_enum_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_enum_field.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
index 420d3c2..cdb3d09 100644
--- a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
@@ -293,7 +293,7 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateSerializationCode(io::Printer* printer) const {
printer->Print(variables_,
- "if (this.$name$.length > 0) {\n");
+ "if (this.$name$ != null && this.$name$.length > 0) {\n");
printer->Indent();
if (descriptor_->options().packed()) {
@@ -317,7 +317,7 @@ GenerateSerializationCode(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateSerializedSizeCode(io::Printer* printer) const {
printer->Print(variables_,
- "if (this.$name$.length > 0) {\n");
+ "if (this.$name$ != null && this.$name$.length > 0) {\n");
printer->Indent();
printer->Print(variables_,