From e66a3e52429c5d8afa38ec7ba3392b7d618d656c Mon Sep 17 00:00:00 2001 From: Timothy Prepscius Date: Tue, 23 Oct 2018 17:51:58 -0400 Subject: [PATCH] moves the comment to a more appropriate position, nullifies the root if referenced in erase --- include/nlohmann/detail/json_pointer.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index e449f3549..1165fb9e6 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -409,15 +409,17 @@ class json_pointer // if we get here, it means that no exception was thrown, so therefore the value specified to // erase exists - // if previous exists, it means that the specified json value was not a root, so, we use the previous - // object and erase from it if (previous) { + // if previous exists, it means that the specified json value was not a root, so, we use the previous + // object and erase from it previous->erase(reference_tokens.back()); } else { - // what to do + // else it means the root was referenced, so we nullify it. + if (ptr != nullptr) + *ptr = {}; } }