From: Vsevolod Stakhov Date: Tue, 13 Feb 2024 15:04:24 +0000 (+0000) Subject: [Fix] Make stat tokens allocation consistent X-Git-Tag: 3.8.2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dca0a49e6d35f157e7ffdf8b0f3e61f707013e09;p=thirdparty%2Frspamd.git [Fix] Make stat tokens allocation consistent --- diff --git a/src/libstat/stat_api.h b/src/libstat/stat_api.h index 1badb2001c..798d0b4819 100644 --- a/src/libstat/stat_api.h +++ b/src/libstat/stat_api.h @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -53,13 +53,14 @@ typedef struct rspamd_stat_token_s { guint flags; } rspamd_stat_token_t; +#define RSPAMD_TOKEN_VALUE_TYPE float typedef struct token_node_s { guint64 data; guint window_idx; guint flags; rspamd_stat_token_t *t1; rspamd_stat_token_t *t2; - float values[]; + RSPAMD_TOKEN_VALUE_TYPE values[0]; } rspamd_token_t; struct rspamd_stat_ctx; diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index d871c7a4e0..e96748a937 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -302,9 +302,8 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx, hashpipe[i].h = 0xfe; hashpipe[i].t = NULL; } - token_size = sizeof(rspamd_token_t) + - sizeof(gdouble) * ctx->statfiles->len; + sizeof(RSPAMD_TOKEN_VALUE_TYPE) * ctx->statfiles->len; g_assert(token_size > 0); for (w = 0; w < words->len; w++) {