mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
Fix itsNextName not clearing when not found
An issue exists when loading vectors of objects where, if the last nvp of the previous object does not exist in the json file, the itsNextName variable within the json serializer is not cleared. This causes the vector serializer to search for that name next (when it should be searching for a nameless object.) The json serializer then throws during the named search. Mild reworking of itsNextName solution
This commit is contained in:
committed by
Shane Grant
parent
f8338dbb73
commit
af0700efb2
@@ -564,18 +564,20 @@ namespace cereal
|
||||
@throws Exception if an expectedName is given and not found */
|
||||
inline void search()
|
||||
{
|
||||
// store pointer to itsNextName locally and reset to nullptr in case search() throws
|
||||
auto localNextName = itsNextName;
|
||||
itsNextName = nullptr;
|
||||
|
||||
// The name an NVP provided with setNextName()
|
||||
if( itsNextName )
|
||||
if( localNextName )
|
||||
{
|
||||
// The actual name of the current node
|
||||
auto const actualName = itsIteratorStack.back().name();
|
||||
|
||||
// Do a search if we don't see a name coming up, or if the names don't match
|
||||
if( !actualName || std::strcmp( itsNextName, actualName ) != 0 )
|
||||
itsIteratorStack.back().search( itsNextName );
|
||||
if( !actualName || std::strcmp( localNextName, actualName ) != 0 )
|
||||
itsIteratorStack.back().search( localNextName );
|
||||
}
|
||||
|
||||
itsNextName = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user