From: Bryan Duxbury Date: Wed, 3 Nov 2010 17:57:38 +0000 (+0000) Subject: THRIFT-977. cpp: Hex Conversion Bug in C++ TJSONProtocol X-Git-Tag: 0.6.0~41 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=4a2bc1b161805833483b14154d07a55be3e63e26;p=common%2Fthrift.git THRIFT-977. cpp: Hex Conversion Bug in C++ TJSONProtocol This patch fixes a silly bug in hex-to-int conversion in TSJONProtocol. Patch: Aravind Narayanan git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1030576 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/src/protocol/TJSONProtocol.cpp b/lib/cpp/src/protocol/TJSONProtocol.cpp index 9859c0f8..5b0b18da 100644 --- a/lib/cpp/src/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/protocol/TJSONProtocol.cpp @@ -194,7 +194,7 @@ static uint8_t hexVal(uint8_t ch) { return ch - '0'; } else if ((ch >= 'a') && (ch <= 'f')) { - return ch - 'a'; + return ch - 'a' + 10; } else { throw TProtocolException(TProtocolException::INVALID_DATA, @@ -211,7 +211,7 @@ static uint8_t hexChar(uint8_t val) { return val + '0'; } else { - return val + 'a'; + return val - 10 + 'a'; } }