Skip to content

Commit 6087180

Browse files
committed
Ensure iterator is kept alive while iterators are active
1 parent 4e822b5 commit 6087180

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/generic/ondemand/json_iterator-inl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ simdjson_really_inline json_iterator::json_iterator(ondemand::parser *_parser) n
2727
// Release the string buf so it can be reused by the next document
2828
logger::log_headers();
2929
}
30-
simdjson_really_inline json_iterator::~json_iterator() noexcept = default;
30+
simdjson_really_inline json_iterator::~json_iterator() noexcept {
31+
// If we have any leases out when we die, it's an error
32+
SIMDJSON_ASSUME(active_lease_depth == 0);
33+
}
3134

3235
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_object() noexcept {
3336
if (*advance() != '{') { logger::log_error(*this, "Not an object"); return INCORRECT_TYPE; }

0 commit comments

Comments
 (0)