Fix for JSON Protocol string-reading methods.

Clear return-by-reference strings before appending to them
in the JSON Protocol reading methods.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665533 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TJSONProtocol.cpp b/lib/cpp/src/protocol/TJSONProtocol.cpp
index 0f3b102..39eb129 100644
--- a/lib/cpp/src/protocol/TJSONProtocol.cpp
+++ b/lib/cpp/src/protocol/TJSONProtocol.cpp
@@ -669,6 +669,7 @@
   uint32_t result = (skipContext ? 0 : context_->read(reader_));
   result += readJSONSyntaxChar(kJSONStringDelimiter);
   uint8_t ch;
+  str.clear();
   while (true) {
     ch = reader_.read();
     ++result;
@@ -702,6 +703,7 @@
   uint32_t result = readJSONString(tmp);
   uint8_t *b = (uint8_t *)tmp.c_str();
   uint32_t len = tmp.length();
+  str.clear();
   while (len >= 4) {
     base64_decode(b, 4);
     str.append((const char *)b, 3);
@@ -721,6 +723,7 @@
 // a valid JSON numeric character.
 uint32_t TJSONProtocol::readJSONNumericChars(std::string &str) {
   uint32_t result = 0;
+  str.clear();
   while (true) {
     uint8_t ch = reader_.peek();
     if (!isJSONNumeric(ch)) {