It could happen that this condition didn't get triggered,
but the structures weren't completely clear. In particular,
the current section could be past KNOT_ANSWER already.
Let's be more conservative here; pkt_recycle() shouldn't be expensive.
I'm not sure why I only ran into this on the new-policy branch,
but it really seems like bug here on master already.
int pkt_renew(knot_pkt_t *pkt, const knot_dname_t *name, uint16_t type)
{
- /* Update packet question if needed. */
- if (!knot_dname_is_equal(knot_pkt_qname(pkt), name)
+ /* Clear the packet if needed. */
+ if (pkt->rrset_count != 0 || !knot_dname_is_equal(knot_pkt_qname(pkt), name)
|| knot_pkt_qtype(pkt) != type || knot_pkt_qclass(pkt) != KNOT_CLASS_IN) {
int ret = kr_pkt_recycle(pkt);
if (ret) return kr_error(ret);