-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Possible fix for #4485 #4487
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
Possible fix for #4485 #4487
Conversation
Throw's an exception when i is nullptr, also added a testcase for this scenario though most likely in the wrong test file.cpp
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @jordan-hoang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also consider the case that
nlohmann::json::parse(nullptr);
is called. This is then interpreted as FILE*
, so please adjust inline file_input_adapter input_adapter(std::FILE* file)
to also throw and exception if nullptr
is provided.
(Also, please update to the latest develop branch to have a green CI) |
Gotcha, ahh so that's what it is, I noticed errors going away when I updated / merged from develop. |
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @jordan-hoang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run "make amalgamate" using Astyle 3.1 (https://astyle.sourceforge.net) to fix the CI issues.
Note "make pretty" is not sufficient as it only indents the files in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments to fix some errors in the CI.
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @jordan-hoang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment.
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @jordan-hoang |
Sorry about all these tiny commits, I make the changes on a windows push em and then do the make amalgamate on a linux vm I have. Should really get make setup for windows so I don't have to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @jordan-hoang |
Thanks a lot!!! |
* Possible fix for nlohmann#4485 Throw's an exception when i is nullptr, also added a testcase for this scenario though most likely in the wrong test file.cpp * quick cleanup * Fix compile issues * moved tests around, changed exceptions, removed a possibly unneeded include * add back include <memory> for testing something * Ninja doesn't like not having a \n, at end of file, adding it back * update input_adapter file to deal with empty/null file ptr. * ran make pretty * added test for inputadapter * ran make amalgamate * Update tests/src/unit-deserialization.cpp Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com> * Update tests/src/unit-deserialization.cpp Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com> * Update input adapters.hpp with new includes * fix unabigious use of _, (there was a double declare) * did the amalagamate * rm duplicate includes * make amalgamate again * reorder * amalgamate * moved it above * amalgamate --------- Co-authored-by: Jordan <jordan-hoang@users.noreply.github.com> Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Description
This fixes an issue with getting a crash when passing in a null string to json::parse(). It instead throws an exception.
Also added in a testcase to check for this.
Link to issue.
#4485
include/nlohmann
directory, runmake amalgamate
to create the single-header filessingle_include/nlohmann/json.hpp
andsingle_include/nlohmann/json_fwd.hpp
. The whole process is described here.