From: Vsevolod Stakhov Date: Fri, 15 Apr 2022 20:09:35 +0000 (+0100) Subject: [Test] Do not cause sigsegv on failed test X-Git-Tag: 3.3~310 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58ed7953ef439d242c4822f837ed745c6869f761;p=thirdparty%2Frspamd.git [Test] Do not cause sigsegv on failed test --- diff --git a/test/rspamd_cxx_unit_dkim.hxx b/test/rspamd_cxx_unit_dkim.hxx index 29facba8ae..802e9ecbfe 100644 --- a/test/rspamd_cxx_unit_dkim.hxx +++ b/test/rspamd_cxx_unit_dkim.hxx @@ -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);