aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/main/java/com/google
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 /java/src/main/java/com/google
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 'java/src/main/java/com/google')
-rw-r--r--java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java b/java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java
index d873462..3a5ee7c 100644
--- a/java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java
+++ b/java/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java
@@ -105,7 +105,7 @@ public final class MessageNanoPrinter {
if (arrayType == byte.class) {
print(fieldName, fieldType, value, indentBuf, buf);
} else {
- int len = Array.getLength(value);
+ int len = value == null ? 0 : Array.getLength(value);
for (int i = 0; i < len; i++) {
Object elem = Array.get(value, i);
print(fieldName, arrayType, elem, indentBuf, buf);