JSONCPP-SRC-0.5.0.TAR.GZ SOURCE Error!!!

Source: Internet
Author: User

Recently in the completion of the establishment, the use of the JsonCpp0.5.0 version number of the source code!

According to the online installation configuration tutorial, set up a good environment can be used!

Here will not waste space to how to build the development environment! Let's go to Google for a moment!

When parsing a JSON file. The program always goes wrong somewhere!

Started to think that the TXT file format is not correct, but also deliberately found a JSON file to engage! This sends the JSON file and executes it!

Is it really a file problem! I'm simplifying my txt file, but it's still a problem, and it's not in my code. is the source of Jsoncpp has a problem! I can't believe it!!

I loaded the source into my project file, once again debug execution, debugging time to locate the problem!

In Json_reader.cpp

BOOL Reader::d ecodedouble (Token &token) {   Double value = 0;   const int buffersize = +;   int count;   int length = Int (Token.end_-token.start_);   if (length <= buffersize)   {      Char buffer[buffersize];      memcpy (buffer, token.start_, length);      Buffer[length] = 0;      Count = sscanf (buffer, "%LF", &value);   }   else   {      std::string buffer (Token.start_, token.end_);      Count = sscanf (Buffer.c_str (), "%lf", &value);   if (count! = 1)      return Adderror ("'" + std::string (Token.start_, Token.end_) + "is not a number.", token); 
   currentvalue () = value;   return true;}

The problem is actually very easy, that is, array access to cross the border!

It would be nice to change the inferred statement in if to length < buffersize!

Test example passed! The correct resolution!

JSONCPP-SRC-0.5.0.TAR.GZ SOURCE Error!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.