[Reviewer Matt] Fixes to leaks and uninitialized conditions flagged by valgrind

Can you review these minor updates to the DNS functions to fix the leaks and uninitialized conditions flagged by valgrind.  The leak is probably pretty serious all things considered, so would definitely be good to get it in before the end of this sprint so we can have it in the next release.

(NB - this doesn't cover your code review feedback yet - I'm hoping to get to that tomorrow.)