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
This commit is contained in:
Paul Yang 2019-08-30 10:47:25 -07:00 committed by GitHub
parent 14b55eb128
commit e9d4e4acbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}