A 'dns_dtenv_t' pointer is passed to an async function without taking
a reference first, which can potentially cause a use-after-free error.
Take a reference, then detach in the async function.
Closes #5820
Merge branch '5820-dns_dtenv-reference-bug-fix' into 'main'