Quellcode durchsuchen

Made JsonDocument's destructor protected (fixes #1480)

Benoit Blanchon vor 5 Jahren
Ursprung
Commit
c70a491f59

+ 5 - 0
CHANGELOG.md

@@ -1,6 +1,11 @@
 ArduinoJson: change log
 =======================
 
+HEAD
+----
+
+* Made `JsonDocument`'s destructor protected (issue #1480)
+
 v6.17.2 (2020-11-14)
 -------
 

+ 3 - 0
extras/tests/FailingBuilds/CMakeLists.txt

@@ -36,3 +36,6 @@ build_should_fail(read_long_long)
 add_executable(write_long_long write_long_long.cpp)
 set_property(TARGET write_long_long PROPERTY CXX_STANDARD 11)
 build_should_fail(write_long_long)
+
+add_executable(delete_jsondocument delete_jsondocument.cpp)
+build_should_fail(delete_jsondocument)

+ 12 - 0
extras/tests/FailingBuilds/delete_jsondocument.cpp

@@ -0,0 +1,12 @@
+// ArduinoJson - arduinojson.org
+// Copyright Benoit Blanchon 2014-2021
+// MIT License
+
+#include <ArduinoJson.h>
+
+struct Stream {};
+
+int main() {
+  JsonDocument* doc = new DynamicJsonDocument(42);
+  delete doc;
+}

+ 2 - 0
src/ArduinoJson/Document/JsonDocument.hpp

@@ -310,6 +310,8 @@ class JsonDocument : public Visitable {
     _data.setNull();
   }
 
+  ~JsonDocument() {}
+
   void replacePool(MemoryPool pool) {
     _pool = pool;
   }