]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Do not cause sigsegv on failed test
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 15 Apr 2022 20:09:35 +0000 (21:09 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 15 Apr 2022 20:09:35 +0000 (21:09 +0100)
test/rspamd_cxx_unit_dkim.hxx

index 29facba8aeaa8906c95d02c4b937a7b7fe456cf5..802e9ecbfea916c1c44ab8290ea7eef49ecc1ec0 100644 (file)
@@ -150,11 +150,15 @@ TEST_CASE("rspamd_dkim_parse_key")
                                CHECK(key != nullptr);
                                char hexbuf[RSPAMD_DKIM_KEY_ID_LEN * 2 + 1];
                                auto *id = rspamd_dkim_key_id(key);
-                               auto hexlen = rspamd_encode_hex_buf(id, RSPAMD_DKIM_KEY_ID_LEN, hexbuf,
-                                               sizeof(hexbuf));
-                               CHECK(hexlen > 0);
-                               CHECK(std::string{hexbuf, (std::size_t) hexlen} == c.expected_id);
-                               rspamd_dkim_key_free(key);
+                               CHECK(id != nullptr);
+
+                               if (id) {
+                                       auto hexlen = rspamd_encode_hex_buf(id, RSPAMD_DKIM_KEY_ID_LEN, hexbuf,
+                                                       sizeof(hexbuf));
+                                       CHECK(hexlen > 0);
+                                       CHECK(std::string{hexbuf, (std::size_t) hexlen} == c.expected_id);
+                                       rspamd_dkim_key_free(key);
+                               }
                        }
                        else {
                                CHECK(key == nullptr);