mirror of
https://github.com/nlohmann/json.git
synced 2026-10-28 00:35:43 +00:00
Fix JSON_DIAGNOSTICS test crash and clang-tidy hit in patch_inplace self-aliasing
The spare-capacity test reallocated non-empty elements through get_ref(), which leaves stale parent pointers under JSON_DIAGNOSTICS; reserve while the array is empty instead. Suppress performance-unnecessary-copy-initialization for the copy that is needed because *this is modified. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
3 files changed
+11
-2
No files matched your search
Generated
+1
@@ -43256,6 +43256,7 @@ public:
|
||||
// a copy when a value is applied as patch to itself
|
||||
if (JSON_HEDLEY_UNLIKELY(&json_patch == this))
|
||||
{
|
||||
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization): *this is modified below
|
||||
const basic_json json_patch_copy = json_patch;
|
||||
patch_inplace(json_patch_copy);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user