Unverified Commit e9d4e4ac authored by Paul Yang's avatar Paul Yang Committed by GitHub

Fix the issue for parsing zero length message (#6592)

* When length is zero, substr returns null instead of emptry string, which breaks the invariable for message.
* Tested in https://github.com/protocolbuffers/protobuf/pull/6560
parent 14b55eb1
......@@ -299,8 +299,12 @@ class CodedInputStream
return false;
}
$buffer = substr($this->buffer, $this->current, $size);
$this->advance($size);
if ($size === 0) {
$buffer = "";
} else {
$buffer = substr($this->buffer, $this->current, $size);
$this->advance($size);
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment