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:
parent
14b55eb128
commit
e9d4e4acbc
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user