]> source.dussan.org Git - rspamd.git/commitdiff
Don't crash if learn cache failed to initialize
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jan 2016 16:24:04 +0000 (16:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jan 2016 16:24:04 +0000 (16:24 +0000)
src/libstat/stat_config.c

index 538ddf8cf639fe205ae965fcbfa6208003a26a73..c8b7bcebc3b2e74b0488fb329850204b9ae761ca 100644 (file)
@@ -196,8 +196,16 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
                                cl->cache = rspamd_stat_get_cache (cache_name);
                                g_assert (cl->cache != NULL);
                                cl->cachecf = cl->cache->init (stat_ctx, cfg, st, cache_obj);
-                               msg_debug_config ("added cache %s for symbol %s",
-                                               cl->cache->name, stf->symbol);
+
+                               if (cl->cachecf == NULL) {
+                                       msg_err_config ("error adding cache %s for symbol %s",
+                                                       cl->cache->name, stf->symbol);
+                                       cl->cache = NULL;
+                               }
+                               else {
+                                       msg_debug_config ("added cache %s for symbol %s",
+                                                       cl->cache->name, stf->symbol);
+                               }
                        }
 
                        if (st->bkcf == NULL) {
@@ -246,7 +254,10 @@ rspamd_stat_close (void)
                        g_slice_free1 (sizeof (*st), st);
                }
 
-               cl->cache->close (cl->cachecf);
+               if (cl->cache && cl->cachecf) {
+                       cl->cache->close (cl->cachecf);
+               }
+
                g_array_free (cl->statfiles_ids, TRUE);
                g_slice_free1 (sizeof (*cl), cl);
        }