From: Vsevolod Stakhov Date: Mon, 25 Jul 2011 11:45:10 +0000 (+0400) Subject: Fix coredumps when learning message with one empty part. X-Git-Tag: 0.4.1~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1cb4c2d898b531c5d325dcc035fc1e9c22ca93a4;p=rspamd.git Fix coredumps when learning message with one empty part. --- diff --git a/src/fuzzy.c b/src/fuzzy.c index 55ed6b9ff..dba76fe69 100644 --- a/src/fuzzy.c +++ b/src/fuzzy.c @@ -478,14 +478,16 @@ fuzzy_compare_hashes (fuzzy_hash_t * h1, fuzzy_hash_t * h2) gint fuzzy_compare_parts (struct mime_text_part *p1, struct mime_text_part *p2) { - if (p1->fuzzy->block_size == p2->fuzzy->block_size) { - return fuzzy_compare_hashes (p1->fuzzy, p2->fuzzy); - } - else if (p1->double_fuzzy->block_size == p2->fuzzy->block_size) { - return fuzzy_compare_hashes (p1->double_fuzzy, p2->fuzzy); - } - else if (p2->double_fuzzy->block_size == p1->fuzzy->block_size) { - return fuzzy_compare_hashes (p2->double_fuzzy, p1->fuzzy); + if (p1->fuzzy != NULL && p2->fuzzy != NULL) { + if (p1->fuzzy->block_size == p2->fuzzy->block_size) { + return fuzzy_compare_hashes (p1->fuzzy, p2->fuzzy); + } + else if (p1->double_fuzzy->block_size == p2->fuzzy->block_size) { + return fuzzy_compare_hashes (p1->double_fuzzy, p2->fuzzy); + } + else if (p2->double_fuzzy->block_size == p1->fuzzy->block_size) { + return fuzzy_compare_hashes (p2->double_fuzzy, p1->fuzzy); + } } return 0;