Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #5
Closed
Open
Issue created Jul 13, 2014 by Administrator@rootContributor

Invalid read when querying for a field that doesn't exist

Created by: shreyasbharath

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 -

static const char *jsonSimpleObject = R"*(
{
   "firstname": "first",
   "lastname": "last"
}
)*";

If I try to get a field that doesn't exist like so -

char *json = strclone( jsonSimpleObject );
JsonHashTable hashTable = parser.parseHashTable( json );

EXPECT_TRUE( hashTable.success() );
EXPECT_THAT( hashTable.getString( "firstname" ), StrEq( "first" ) );
EXPECT_THAT( hashTable.getString( "lastname" ), StrEq( "last" ) );
EXPECT_THAT( hashTable.getString( "middlename" ), Eq( nullptr ) );

The error reported by Valgrind is as below -

==16231== Conditional jump or move depends on uninitialised value(s)
==16231==    at 0x81983E5: JsonObjectBase::getNestedTokenCount(jsmntok_t*) (JsonObjectBase.cpp:18)
==16231==    by 0x8198253: JsonHashTable::getToken(char const*) (JsonHashTable.cpp:44)
==16231==    by 0x81983A5: JsonHashTable::getString(char const*) (JsonHashTable.cpp:83)
==16231==    by 0x80EF597: 
Assignee
Assign to
Time tracking