diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-04 18:22:52 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-04 18:22:52 +0100 |
commit | 3be27b3358b4c4fd092af6979809eb237d1bff6a (patch) | |
tree | f8687eaa8affec492e32f19f106ffeaf355ce57e /src/libstat/tokenizers | |
parent | d07c0aa5edf25f4b98c4d20639b9c501164806bf (diff) | |
download | rspamd-3be27b3358b4c4fd092af6979809eb237d1bff6a.tar.gz rspamd-3be27b3358b4c4fd092af6979809eb237d1bff6a.zip |
[Fix] Fix processing of small tokens vectors
Diffstat (limited to 'src/libstat/tokenizers')
-rw-r--r-- | src/libstat/tokenizers/osb.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index 6be660b41..f0e351bb5 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -290,7 +290,11 @@ rspamd_tokenizer_osb (struct rspamd_stat_ctx *ctx, } hashpipe = g_alloca (window_size * sizeof (hashpipe[0])); - memset (hashpipe, 0xfe, window_size * sizeof (hashpipe[0])); + for (i = 0; i < window_size; i++) { + hashpipe[i].h = 0xfe; + hashpipe[i].t = NULL; + } + token_size = sizeof (rspamd_token_t) + sizeof (gdouble) * ctx->statfiles->len; g_assert (token_size > 0); @@ -364,8 +368,9 @@ rspamd_tokenizer_osb (struct rspamd_stat_ctx *ctx, } } - if (processed <= window_size) { - memmove (hashpipe, &hashpipe[window_size - processed + 1], + if (processed > 1 && processed <= window_size) { + processed --; + memmove (hashpipe, &hashpipe[window_size - processed], processed * sizeof (hashpipe[0])); for (i = 1; i < processed; i++) { |