From c1298e69a6b308bbe3f0db41415f24c8cdbc5a73 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 15 Jul 2021 12:52:17 +0200 Subject: [PATCH] :bug: fix leak for strings --- include/nlohmann/detail/conversions/to_json.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 1b002ddb5..960d92e20 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -236,7 +236,10 @@ template::value, int> = 0> void to_json(BasicJsonType& j, const CompatibleString& s) { - j.m_value.destroy(j.m_type); + if (!j.is_null()) + { + j = nullptr; + } external_constructor::construct(j, s); }