[
https://issues.apache.org/jira/browse/THRIFT-2026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15931529#comment-15931529
]
ASF GitHub Bot commented on THRIFT-2026:
----------------------------------------
Github user jbapple-cloudera commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1214#discussion_r106796209
--- Diff: lib/cpp/src/thrift/protocol/TCompactProtocol.tcc ---
@@ -387,7 +389,11 @@ uint32_t
TCompactProtocolT<Transport_>::writeVarint64(uint64_t n) {
*/
template <class Transport_>
uint64_t TCompactProtocolT<Transport_>::i64ToZigzag(const int64_t l) {
- return (l << 1) ^ (l >> 63);
+ const int64_t m = l >> 63;
+ uint64_t p, q;
+ memcpy(&p, &l, sizeof(p));
+ memcpy(&q, &m, sizeof(q));
+ return p = (p << 1) ^ q;
--- End diff --
Good point.
> Fix TCompactProtocol 64 bit builds
> ----------------------------------
>
> Key: THRIFT-2026
> URL: https://issues.apache.org/jira/browse/THRIFT-2026
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.9
> Environment: Mac 64, Win 64, Linux 64
> Reporter: Ben Craig
> Assignee: Ben Craig
> Fix For: 0.9.2
>
> Attachments: compact_int_stuff.patch
>
>
> TCompactProtocol has several places where it truncates a size_t to a 32-bit
> value.
> TCompactProtocol also does bitwise operations on signed values, which has
> undefined behavior.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)