aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src/Google/Protobuf/Internal/GPBWire.php
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-02-07 21:33:28 -0800
committerGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-03-15 14:16:49 -0700
commitf23869c6154d8b083ee3417fac277bc25e13a4ac (patch)
tree2e9ea1cfcc88211ac1e364155d696c808acb11ba /php/src/Google/Protobuf/Internal/GPBWire.php
parent014a5507fb4b1ccc12f35ff313b8a04c05d69b7f (diff)
Bug fix: When encoding, negative int32 values should be padded to int64 (#2660)
in order to be wire compatible.
Diffstat (limited to 'php/src/Google/Protobuf/Internal/GPBWire.php')
-rw-r--r--php/src/Google/Protobuf/Internal/GPBWire.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/php/src/Google/Protobuf/Internal/GPBWire.php b/php/src/Google/Protobuf/Internal/GPBWire.php
index f75e0861..67eb1bee 100644
--- a/php/src/Google/Protobuf/Internal/GPBWire.php
+++ b/php/src/Google/Protobuf/Internal/GPBWire.php
@@ -403,10 +403,14 @@ class GPBWire
return self::varint32Size($tag);
}
- public static function varint32Size($value)
+ public static function varint32Size($value, $sign_extended = false)
{
if ($value < 0) {
- return 5;
+ if ($sign_extended) {
+ return 10;
+ } else {
+ return 5;
+ }
}
if ($value < (1 << 7)) {
return 1;