-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Invalid read when querying for a field that doesn't exist #5
Comments
Valgrind says it's in
It could be either: Unfortunately, it's not easy for me to run Valgrind, because I'm using Visual Studio for the tests. |
I had a closer look and it appears that the "tokens" member variable in JsonParser.h is not initialised at all. I think maybe it should be zeroed in the constructor or else it will be undefined when you try to read past the end of the last token. |
Writing zeros in the array, just for the sake of it would be a complete waste.
Do you know which |
Yup it is the last EXPECT in that test. I'll try out the latest version of Jsmn tomorrow (if we are not already using it). |
Good! |
I can confirm that it is token->start that is uninitialised, it was a large negative number when I stepped through the code. |
I refactored I pushed a fix into the master branch, please give it a try. |
I can confirm that this bug has been fixed. Thanks :) |
Hi again,
I was writing some simple parsing tests and came across this error when I ran my test on Valgrind.
Given a test vector like this one -
If I try to get a field that doesn't exist like so -
The error reported by Valgrind is as below -
The text was updated successfully, but these errors were encountered: