]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix crash on empty maps
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:50:56 +0000 (18:50 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:50:56 +0000 (18:50 +0100)
Issue: #695
Reported by: @moisseev

src/libutil/map.c

index 0c8e6b925a7479efeebbc81daf650d456e43b812..c5123631ffb6540816ff5c221da6a86b28e525d7 100644 (file)
@@ -1128,13 +1128,17 @@ static void
 rspamd_map_backend_dtor (struct rspamd_map_backend *bk)
 {
        if (bk->protocol == MAP_PROTO_FILE) {
-               g_free (bk->data.fd->filename);
-               g_slice_free1 (sizeof (*bk->data.fd), bk->data.fd);
+               if (bk->data.fd) {
+                       g_free (bk->data.fd->filename);
+                       g_slice_free1 (sizeof (*bk->data.fd), bk->data.fd);
+               }
        }
        else {
-               g_free (bk->data.hd->host);
-               g_free (bk->data.hd->path);
-               g_slice_free1 (sizeof (*bk->data.hd), bk->data.hd);
+               if (bk->data.hd) {
+                       g_free (bk->data.hd->host);
+                       g_free (bk->data.hd->path);
+                       g_slice_free1 (sizeof (*bk->data.hd), bk->data.hd);
+               }
        }
 
        g_slice_free1 (sizeof (*bk), bk);