Giter Club home page Giter Club logo

Comments (8)

bblanchon avatar bblanchon commented on May 22, 2024

Valgrind says it's in JsonObjectBase.cpp:18 which is:

while (token->start < end)

It could be either: token, token->end or token->start that is not initialized.

Unfortunately, it's not easy for me to run Valgrind, because I'm using Visual Studio for the tests.
Maybe it's time for me to move to GCC and gtest...

from arduinojson.

shreyasbharath avatar shreyasbharath commented on May 22, 2024

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.

from arduinojson.

bblanchon avatar bblanchon commented on May 22, 2024

Writing zeros in the array, just for the sake of it would be a complete waste.
But if there is really a bug, we should be able to write a unit test and fix it.

tokens should be initialized by jsmn_parse(), but maybe some of them are not.
Can you try with the latest version of jsmn?

Do you know which EXPECT_ line triggers this error?
I guess it could be the last one, because the key doesn't exists.

from arduinojson.

shreyasbharath avatar shreyasbharath commented on May 22, 2024

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).

from arduinojson.

bblanchon avatar bblanchon commented on May 22, 2024

Good!
I'm going to write a unit test.
There must be a sleeping bug here.

from arduinojson.

shreyasbharath avatar shreyasbharath commented on May 22, 2024

I can confirm that it is token->start that is uninitialised, it was a large negative number when I stepped through the code.

from arduinojson.

bblanchon avatar bblanchon commented on May 22, 2024

I refactored getNestedTokenCount().

I pushed a fix into the master branch, please give it a try.

from arduinojson.

shreyasbharath avatar shreyasbharath commented on May 22, 2024

I can confirm that this bug has been fixed. Thanks :)

from arduinojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.