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

contains() is sometimes causing stack-based buffer overrun exceptions #1683

Closed
hokpe opened this issue Jul 23, 2019 · 2 comments
Closed

contains() is sometimes causing stack-based buffer overrun exceptions #1683

hokpe opened this issue Jul 23, 2019 · 2 comments

Comments

@hokpe
Copy link

hokpe commented Jul 23, 2019

First of all, this is very good c++ json library. thank you.

  • What is the issue you have?
    I noticed that the sw is sometimes throwing an exception (Stack cookie instrumentation code detected a stack-based buffer overrun.), when I was using json.contains("") method. It is not happening every time with the same data. So is there any other reports or similar observations noticed? I can't integrate this to our code base, if I'm uncertain about this library.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    Because I'm not able to reproduce this every time, I can't provide such a code.
    But basically I read the json file using std::ifstream and then I was checking that is json object containing the attribute what I was looking for. And the value of that attribute was an object.

  • Which compiler and operating system are you using? Is it a supported compiler?
    Microsoft Visual C++ 2017, target platform Windows 10 (SDK 10.0.17134.0)

  • Did you use a released version of the library or the version from the develop branch?
    Release version 3.6.1

@nlohmann
Copy link
Owner

I never experienced any issue. The contains function is rather simple:

template<typename KeyT, typename std::enable_if<
             not std::is_same<KeyT, json_pointer>::value, int>::type = 0>
bool contains(KeyT && key) const
{
    return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
}

So all it is doing is compare an enum value in is_object and compare two std::map::iterators. Without stack trace or example, I would not know how to help.

@hokpe
Copy link
Author

hokpe commented Jul 23, 2019

Ok, thank you for quick response.

@hokpe hokpe closed this as completed Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants