]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Allocate variable in the pool and avoid malloc
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Mar 2020 15:59:20 +0000 (15:59 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Mar 2020 15:59:20 +0000 (15:59 +0000)
src/libstat/learn_cache/redis_cache.c

index 301232d28e026a13f7d421a81738219c54984130..a73a79b8c7e049d8ae7f718e1ff6281ae3b9df84 100644 (file)
@@ -222,7 +222,10 @@ rspamd_stat_cache_redis_generate_id (struct rspamd_task *task)
 
        rspamd_cryptobox_hash_final (&st, out);
 
-       b32out = rspamd_encode_base32 (out, sizeof (out));
+       b32out = rspamd_mempool_alloc (task->task_pool,
+                       sizeof (out) * 8 / 5 + 2);
+       rspamd_encode_base32_buf (out, sizeof (out), b32out,
+                       sizeof (out) * 8 / 5 + 2);
        g_assert (b32out != NULL);
        rspamd_mempool_set_variable (task->task_pool, "words_hash", b32out, g_free);
 }