mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Fix crash when adding an object member in a too small JsonDocument
				
					
				
			This commit is contained in:
		| @@ -1,6 +1,11 @@ | |||||||
| ArduinoJson: change log | ArduinoJson: change log | ||||||
| ======================= | ======================= | ||||||
|  |  | ||||||
|  | HEAD | ||||||
|  | ---- | ||||||
|  |  | ||||||
|  | * Fix crash when adding an object member in a too small `JsonDocument` | ||||||
|  |  | ||||||
| v6.19.0 (2022-01-08) | v6.19.0 (2022-01-08) | ||||||
| ------- | ------- | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,6 +35,12 @@ TEST_CASE("JsonDocument::overflowed()") { | |||||||
|     CHECK(doc.overflowed() == false); |     CHECK(doc.overflowed() == false); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   SECTION("returns true after a failed member add") { | ||||||
|  |     StaticJsonDocument<1> doc; | ||||||
|  |     doc["example"] = true; | ||||||
|  |     CHECK(doc.overflowed() == true); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   SECTION("returns true after a failed deserialization") { |   SECTION("returns true after a failed deserialization") { | ||||||
|     StaticJsonDocument<JSON_ARRAY_SIZE(1)> doc; |     StaticJsonDocument<JSON_ARRAY_SIZE(1)> doc; | ||||||
|     deserializeJson(doc, "[\"example\"]"); |     deserializeJson(doc, "[\"example\"]"); | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ struct SlotKeySetter { | |||||||
| template <typename TAdaptedString, typename TStoragePolicy> | template <typename TAdaptedString, typename TStoragePolicy> | ||||||
| inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, | inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, | ||||||
|                        TStoragePolicy storage) { |                        TStoragePolicy storage) { | ||||||
|  |   if (!var) | ||||||
|  |     return false; | ||||||
|   return storage.store(key, pool, SlotKeySetter(var)); |   return storage.store(key, pool, SlotKeySetter(var)); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user