Author: bryanduxbury
Date: Tue May 12 16:44:52 2009
New Revision: 773974
URL: http://svn.apache.org/viewvc?rev=773974&view=rev
Log:
THRIFT-499. php: Thrift_protocol PHP extension does not handle signedness
correctly
Cast all the number types to signed values before making PHP longs out of them.
Modified:
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
Modified:
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp?rev=773974&r1=773973&r2=773974&view=diff
==============================================================================
---
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
(original)
+++
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
Tue May 12 16:44:52 2009
@@ -441,23 +441,23 @@
case T_BYTE: {
uint8_t c;
transport.readBytes(&c, 1);
- RETURN_LONG(c);
+ RETURN_LONG((int8_t)c);
}
case T_I16: {
uint16_t c;
transport.readBytes(&c, 2);
- RETURN_LONG(ntohs(c));
+ RETURN_LONG((int16_t)ntohs(c));
}
case T_I32: {
uint32_t c;
transport.readBytes(&c, 4);
- RETURN_LONG(ntohl(c));
+ RETURN_LONG((int32_t)ntohl(c));
}
case T_U64:
case T_I64: {
uint64_t c;
transport.readBytes(&c, 8);
- RETURN_LONG(ntohll(c));
+ RETURN_LONG((int64_t)ntohll(c));
}
case T_DOUBLE: {
union {