mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Fixed serializeJson(doc, String) when allocation fails (fixes #1572)
This commit is contained in:
		| @@ -22,10 +22,10 @@ class Writer< ::String, void> { | ||||
|   } | ||||
|  | ||||
|   size_t write(uint8_t c) { | ||||
|     ARDUINOJSON_ASSERT(_size < bufferCapacity); | ||||
|     _buffer[_size++] = static_cast<char>(c); | ||||
|     if (_size + 1 >= bufferCapacity) | ||||
|       flush(); | ||||
|       if (flush() != 0) | ||||
|         return 0; | ||||
|     _buffer[_size++] = static_cast<char>(c); | ||||
|     return 1; | ||||
|   } | ||||
|  | ||||
| @@ -36,14 +36,15 @@ class Writer< ::String, void> { | ||||
|     return n; | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   void flush() { | ||||
|   size_t flush() { | ||||
|     ARDUINOJSON_ASSERT(_size < bufferCapacity); | ||||
|     _buffer[_size] = 0; | ||||
|     *_destination += _buffer; | ||||
|     _size = 0; | ||||
|     if (_destination->concat(_buffer)) | ||||
|       _size = 0; | ||||
|     return _size; | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   ::String *_destination; | ||||
|   char _buffer[bufferCapacity]; | ||||
|   size_t _size; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user