]> source.dussan.org Git - rspamd.git/commitdiff
Check upstream before freeing.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 May 2015 14:18:07 +0000 (15:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 May 2015 14:18:07 +0000 (15:18 +0100)
src/libutil/upstream.c

index 6aa447042199faa46b8b84d60bce449c53ed9c89..a0ffd56e19a47a5b01bdc9bd3cb8029213d1082d 100644 (file)
@@ -518,17 +518,19 @@ rspamd_upstreams_destroy (struct upstream_list *ups)
        guint i;
        struct upstream *up;
 
-       g_ptr_array_free (ups->alive, TRUE);
+       if (ups != NULL) {
+               g_ptr_array_free (ups->alive, TRUE);
 
-       for (i = 0; i < ups->ups->len; i ++) {
-               up = g_ptr_array_index (ups->ups, i);
-               up->ls = NULL;
-               REF_RELEASE (up);
-       }
+               for (i = 0; i < ups->ups->len; i ++) {
+                       up = g_ptr_array_index (ups->ups, i);
+                       up->ls = NULL;
+                       REF_RELEASE (up);
+               }
 
-       g_ptr_array_free (ups->ups, TRUE);
-       rspamd_mutex_free (ups->lock);
-       g_slice_free1 (sizeof (*ups), ups);
+               g_ptr_array_free (ups->ups, TRUE);
+               rspamd_mutex_free (ups->lock);
+               g_slice_free1 (sizeof (*ups), ups);
+       }
 }
 
 static void