protobuf-php/protobuf

Exception when reuse toStream on same object(without change value of field)

Mararok opened this issue · 1 comments

I found some problem :(
When I called toStream second time on message without any changes it's throws me Exception
Reproduce instruction:

  1. .proto file with bytes field
import "php.proto";

message Test {
  required bytes foo = 1;
}
  1. script used generated class
$data = new Test();
$data->setFoo("foo");

$data->toStream();
$data->toStream();

Will produce exception on second call toStream:

RuntimeException: Failed to write stream with 3 bytes in vendor/protobuf-php/protobuf/src/Stream.php:238

Thanks for reporting @Mararok !
This should fix the problem : c0da95f