From 7a7f4d1da0f6f98f126e8840f08c5a683e347294 Mon Sep 17 00:00:00 2001 From: AJ Lewis Date: Tue, 13 Jan 2015 15:43:51 -0600 Subject: [PATCH] If a submessage has 0 length, don't try to decode it. This prevents the decoder from thinking the next fields in the parent message are a part of the submessage. --- library/DrSlump/Protobuf/Codec/Binary.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/DrSlump/Protobuf/Codec/Binary.php b/library/DrSlump/Protobuf/Codec/Binary.php index 167ac5e..1e15a25 100644 --- a/library/DrSlump/Protobuf/Codec/Binary.php +++ b/library/DrSlump/Protobuf/Codec/Binary.php @@ -266,7 +266,11 @@ protected function decodeMessage($reader, \DrSlump\Protobuf\Message $message, $l $submessage = new $submessage; $len = $reader->varint(); - $value = $this->decodeMessage($reader, $submessage, $len); + if ($len) { + $value = $this->decodeMessage($reader, $submessage, $len); + } else { + $value = $submessage; + } } else { $value = $this->decodeSimpleType($reader, $type, $wire); }