From: Vsevolod Stakhov Date: Mon, 4 May 2015 14:18:07 +0000 (+0100) Subject: Check upstream before freeing. X-Git-Tag: 0.9.0~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d14083964c313c566d1cd6017a4f622f2ef97ef5;p=thirdparty%2Frspamd.git Check upstream before freeing. --- diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index 6aa4470421..a0ffd56e19 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -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