Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report #20

Closed
richard-guan-dev opened this issue Jul 31, 2014 · 6 comments
Closed

Bug Report #20

richard-guan-dev opened this issue Jul 31, 2014 · 6 comments

Comments

@richard-guan-dev
Copy link

When I parse a string like "1", "12". JsonCPP just goes wrong.
parse function return true

@richard-guan-dev
Copy link
Author

In face, if the string is begin with a number, the program will crash.

@cdunn2001
Copy link
Contributor

Can you add a test-case to the unit-test suite?

@raandoom
Copy link

Hi. There is bug report about this: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753560
This report contains patch and simple valid program for checking bug. Hope it helps.

@cdunn2001
Copy link
Contributor

I don't follow the logic of the patch submitter. If the exception is thrown, then the type must be objectValue or arrayValue. If the parser is interpreting 9001 as one of those, then the bug seems to be in the parser. Can anyone prove and find that bug? (I don't have time.)

The patch would alter semantics. (Maybe null should never have been considered an array and an object, but it is.)

@raandoom
Copy link

Ok. I found something. This problem in Debian (maybe other distros) because it has old version of Value::asString() function in json_value.cpp. It looks like this:

std::string 
Value::asString() const
{
   switch ( type_ )
   {
   case nullValue:
      return "";
   case stringValue:
      return value_.string_ ? value_.string_ : "";
   case booleanValue:
      return value_.bool_ ? "true" : "false";
   case intValue:
   case uintValue:
   case realValue:
   case arrayValue:
   case objectValue:
      JSON_FAIL_MESSAGE( "Type is not convertible to string" );
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   return ""; // unreachable
}

But current version use valueToString() function for types.

@cdunn2001
Copy link
Contributor

So the current version is fine, right?

If you branch the Debian version and fix that, we'd be happy to accept that. But I doubt Debian would bother to pull the fix.

Close. (I love your username, btw.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants