]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Set proper size
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 14 Dec 2023 16:46:39 +0000 (16:46 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 14 Dec 2023 16:46:39 +0000 (16:46 +0000)
src/libstat/backends/redis_backend.cxx

index 6b3c9aae464fa2629320e922cd29cb4093d72818..026bb45033273149c608278a2cc3ce6c09dad8c5 100644 (file)
@@ -668,8 +668,9 @@ rspamd_redis_serialize_tokens(struct rspamd_task *task, const gchar *prefix, GPt
        int i;
        PTR_ARRAY_FOREACH(tokens, i, tok)
        {
-               char *numbuf = (char *) g_alloca(sizeof(max_int64_str) + prefix_len + 1);
-               auto r = rspamd_snprintf(numbuf, sizeof(numbuf), "%s_%uL", tok->data);
+               auto numbuf_len = sizeof(max_int64_str) + prefix_len + 1;
+               auto *numbuf = (char *) g_alloca(numbuf_len);
+               auto r = rspamd_snprintf(numbuf, numbuf_len, "%s_%uL", tok->data);
                *p++ = (gchar) ((r & 0xff) | 0xa0);
 
                memcpy(p, &numbuf, r);