Skip to content

Commit 85fbe19

Browse files
committed
Fix JsonVariantTests
1 parent 305d535 commit 85fbe19

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/ArduinoJson/Array/ArrayImpl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ inline ArrayImpl::iterator ArrayImpl::at(size_t index) const {
2020
}
2121

2222
inline VariantData* ArrayImpl::addElement() {
23+
if (!data_)
24+
return nullptr;
25+
ARDUINOJSON_ASSERT(resources_ != nullptr);
2326
auto slot = resources_->allocVariant();
2427
if (!slot)
2528
return nullptr;

src/ArduinoJson/Collection/CollectionImpl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ inline CollectionImpl::iterator CollectionImpl::createIterator() const {
3232
}
3333

3434
inline void CollectionImpl::appendOne(Slot<VariantData> slot) {
35+
ARDUINOJSON_ASSERT(data_ != nullptr);
36+
ARDUINOJSON_ASSERT(resources_ != nullptr);
37+
3538
if (data_->tail != NULL_SLOT) {
3639
auto tail = resources_->getVariant(data_->tail);
3740
tail->setNext(slot.id());
@@ -44,6 +47,9 @@ inline void CollectionImpl::appendOne(Slot<VariantData> slot) {
4447

4548
inline void CollectionImpl::appendPair(Slot<VariantData> key,
4649
Slot<VariantData> value) {
50+
ARDUINOJSON_ASSERT(data_ != nullptr);
51+
ARDUINOJSON_ASSERT(resources_ != nullptr);
52+
4753
key->setNext(value.id());
4854

4955
if (data_->tail != NULL_SLOT) {

src/ArduinoJson/Object/ObjectImpl.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inline void ObjectImpl::removeMember(TAdaptedString key) {
4747

4848
template <typename TAdaptedString>
4949
inline VariantData* ObjectImpl::addMember(TAdaptedString key) {
50+
if (!data_)
51+
return nullptr;
52+
ARDUINOJSON_ASSERT(resources_ != nullptr);
53+
5054
auto keySlot = resources_->allocVariant();
5155
if (!keySlot)
5256
return nullptr;
@@ -64,6 +68,10 @@ inline VariantData* ObjectImpl::addMember(TAdaptedString key) {
6468
}
6569

6670
inline VariantData* ObjectImpl::addPair(VariantData** value) {
71+
if (!data_)
72+
return nullptr;
73+
ARDUINOJSON_ASSERT(resources_ != nullptr);
74+
6775
auto keySlot = resources_->allocVariant();
6876
if (!keySlot)
6977
return nullptr;

0 commit comments

Comments
 (0)