Fix crash in mDNS caching logic.

This occured when the cache expiration deleted the first cached entry,
whose memory was freed but then fed into the entry iterator again.