]> source.dussan.org Git - rspamd.git/commitdiff
* Fix inserting one list to another in spf parser (include border elements)
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 15 Dec 2009 14:38:11 +0000 (17:38 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 15 Dec 2009 14:38:11 +0000 (17:38 +0300)
src/spf.c

index 662ae285b59613761804ba31e4a7703e3fecf370..49ef39891a1afa7ef9f5b927cbb6e8f2bda17667 100644 (file)
--- a/src/spf.c
+++ b/src/spf.c
@@ -285,18 +285,29 @@ spf_record_dns_callback (int result, char type, int count, int ttl, void *addres
                                                                        /* Insert new list in place of include element */
                                                                        last = g_list_last (cb->rec->addrs);
 
-                                                                       if (elt->prev) {
-                                                                               elt->prev->next = cb->rec->addrs;
-                                                                       }
-                                                                       if (elt->next) {
-                                                                               elt->next->prev = last;
+                                                                       if (elt->prev == NULL && elt->next == NULL) {
+                                                                               g_list_free1 (elt);
                                                                        }
 
-                                                                       cb->rec->addrs->prev = elt->prev;
-                                                                       last->next = elt->next;
+                                                                       else {
+
+                                                                               if (elt->prev) {
+                                                                                       elt->prev->next = cb->rec->addrs;
+                                                                               }
+                                                                               else {
+                                                                                       /* Elt is the first element, so we need to shift temporary list */
+                                                                                       tmp = elt->next;
+                                                                               }
+                                                                               if (elt->next) {
+                                                                                       elt->next->prev = last;
+                                                                                       last->next = elt->next;
+                                                                               }
 
-                                                                       cb->rec->addrs = tmp;
-                                                                       g_list_free1 (elt);
+                                                                               cb->rec->addrs->prev = elt->prev;
+
+                                                                               cb->rec->addrs = tmp;
+                                                                               g_list_free1 (elt);
+                                                                       }
                                                                }
                                                        }
                                                }