From 898f42982675fd0987415eb7be8549e0a10d3c34 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Thu, 15 Apr 2021 11:30:56 +0200 Subject: [PATCH] Fixed member-call-on-null-pointer in getMember() when array is empty --- CHANGELOG.md | 1 + src/ArduinoJson/Collection/CollectionImpl.hpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cdb3b24..eef086b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ HEAD * Changed `JsonVariantConst::is()` to return `false` (issue #1412) * Simplified `JsonVariant::as()` to always return `T` (see below) * Updated folders list in `.mbedignore` (PR #1515 by @AGlass0fMilk) +* Fixed member-call-on-null-pointer in `getMember()` when array is empty > ### BREAKING CHANGES > diff --git a/src/ArduinoJson/Collection/CollectionImpl.hpp b/src/ArduinoJson/Collection/CollectionImpl.hpp index ee8ee36b..49a24bee 100644 --- a/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -115,6 +115,8 @@ inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { } inline VariantSlot* CollectionData::getSlot(size_t index) const { + if (!_head) + return 0; return _head->next(index); }