[9.16] Resolve "Error path cleanup issues in dns_catz_new_zones() and dns_catz_new_zone()"
Partial backport of !7605 (merged).
The 6f8fb024 commit is not backported, because the hash table leak, which was fixed there, does not exist in the v9_16
branch.
Closes #3900 (closed)