Open
Description
A statement provided by StatementIterator can be leaked until the Database is closed if the iterator is not run to completion. A statement is not freed until next
is called for the following iteration, which might not happen if, for example, a for...of
loop is exited via break
, return
, or thrown exception.
Careful coding can work around this issue, but that code will also be uglier and harder to read. A better fix would be to implement the optional return
method on the iterator to reclaim its resources, as that will be automatically called on early loop termination.