From d2dfda65833075648ecbc035dec40e22c88d3060 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 31 Aug 2020 13:23:38 -0700 Subject: [PATCH] Ensure iterator is kept alive while iterators are active --- src/generic/ondemand/json_iterator-inl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generic/ondemand/json_iterator-inl.h b/src/generic/ondemand/json_iterator-inl.h index b562f6cd6..d56809ad2 100644 --- a/src/generic/ondemand/json_iterator-inl.h +++ b/src/generic/ondemand/json_iterator-inl.h @@ -27,7 +27,10 @@ simdjson_really_inline json_iterator::json_iterator(ondemand::parser *_parser) n // Release the string buf so it can be reused by the next document logger::log_headers(); } -simdjson_really_inline json_iterator::~json_iterator() noexcept = default; +simdjson_really_inline json_iterator::~json_iterator() noexcept { + // If we have any leases out when we die, it's an error + SIMDJSON_ASSUME(active_lease_depth == 0); +} SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::start_object() noexcept { if (*advance() != '{') { logger::log_error(*this, "Not an object"); return INCORRECT_TYPE; }