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

Value constructor for char * is crashing on NULL value in current version jsoncpp 0.6.0 #91

Closed
abhianshu opened this issue Nov 26, 2014 · 2 comments

Comments

@abhianshu
Copy link

In earlier version of Json::value constructor i.e. Value( const char *value ) was handling NULL as parameter gracefully But crashing In version jsoncpp 0.6.0.

Why this change is done, any specific issue related to that?

@BillyGoto
Copy link

The NULL literal isn't a const char_, so this would be very dangerous: Value(NULL). You don't know what constructor you're calling. Value(static_cast<const char_>(NULL)) would be more clear, but even then I think the code has a logical problem. A C++ std::string can be constructed with a (const char*)0 in the sense that it compiles, but it's undefined behavior. That string constructor requires that the argument point to an array of char, and passing 0 is a violation of that precondition.

@cdunn2001
Copy link
Contributor

Agreed.

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