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
pull/6601/head
Paul Yang 6 years ago committed by GitHub
parent 14b55eb128
commit e9d4e4acbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      php/src/Google/Protobuf/Internal/CodedInputStream.php

@ -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…
Cancel
Save