Clear qctx->zversion when clearing qctx->zrdataset et al in lib/ns/query.c:qctx_freedata. The uncleared pointer could lead to an assertion failure if zone data needed to be re-saved which could happen with stale data support enabled.
isc_stats_increment