diff --git a/tests/libknot/test_edns.c b/tests/libknot/test_edns.c
index 6419f07d11b045d962a08fce13a492c736f85d9f..0901f68d1891e96646222b6102b6e4802c9e1b2a 100644
--- a/tests/libknot/test_edns.c
+++ b/tests/libknot/test_edns.c
@@ -69,6 +69,10 @@ static const uint16_t DO_FLAG = (uint16_t)1 << 15;
 static void check_ttl(knot_rdata_t *rdata, uint8_t ext_rcode, uint8_t ver,
                       uint16_t flags, char *msg)
 {
+	if (rdata == NULL) {
+		return;
+	}
+
 	/* TTL should be stored in machine byte order.
 	   We need network byte order to compare its parts. */
 	uint8_t ttl_wire[4] = { 0, 0, 0, 0 };