Skip to content

Commit 4a5e58c

Browse files
committed
Integrated part of Patch #2839016, fixing default iterator initialization when using internal map.
1 parent 2bcfb63 commit 4a5e58c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

include/json/value.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,13 @@ namespace Json {
637637
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
638638
struct IteratorState
639639
{
640+
IteratorState()
641+
: map_(0)
642+
, link_(0)
643+
, itemIndex_(0)
644+
, bucketIndex_(0)
645+
{
646+
}
640647
ValueInternalMap *map_;
641648
ValueInternalLink *link_;
642649
BucketIndex itemIndex_;
@@ -729,6 +736,12 @@ namespace Json {
729736
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
730737
struct IteratorState // Must be a POD
731738
{
739+
IteratorState()
740+
: array_(0)
741+
, currentPageIndex_(0)
742+
, currentItemIndex_(0)
743+
{
744+
}
732745
ValueInternalArray *array_;
733746
Value **currentPageIndex_;
734747
unsigned int currentItemIndex_;

src/lib_json/json_valueiterator.inl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ ValueIteratorBase::ValueIteratorBase()
1414
#ifndef JSON_VALUE_USE_INTERNAL_MAP
1515
: current_()
1616
, isNull_( true )
17+
{
18+
}
1719
#else
18-
# error fix me // Need to handle uninitialized iterator comparison for experimental maps
19-
#endif
20+
: isArray_( true )
21+
, isNull_( true )
2022
{
23+
iterator_.array_ = ValueInternalArray::IteratorState();
2124
}
25+
#endif
2226

2327

2428
#ifndef JSON_VALUE_USE_INTERNAL_MAP

0 commit comments

Comments
 (0)