commit cf8665e: [Minor] Fix some calcs

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jul 16 15:21:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-16 16:14:43 +0100
URL: https://github.com/rspamd/rspamd/commit/cf8665ebe3f5a2acdc740076a70cd8df6f73d8f3 (HEAD -> master)

[Minor] Fix some calcs

---
 src/libserver/composites/composites.cxx          | 3 ++-
 src/libserver/composites/composites_internal.hxx | 2 +-
 src/libserver/composites/composites_manager.cxx  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libserver/composites/composites.cxx b/src/libserver/composites/composites.cxx
index b03edaf71..99a2038c3 100644
--- a/src/libserver/composites/composites.cxx
+++ b/src/libserver/composites/composites.cxx
@@ -88,7 +88,8 @@ struct composites_data {
 
 	explicit composites_data(struct rspamd_task *task, struct rspamd_scan_result *mres) :
 			task(task), composite(nullptr), metric_res(mres) {
-		checked.resize(rspamd_composites_manager_nelts(task->cfg->composites_manager) * 2);
+		checked.resize(rspamd_composites_manager_nelts(task->cfg->composites_manager) * 2,
+				false);
 	}
 };
 
diff --git a/src/libserver/composites/composites_internal.hxx b/src/libserver/composites/composites_internal.hxx
index 12fa3ecb2..c38f3d377 100644
--- a/src/libserver/composites/composites_internal.hxx
+++ b/src/libserver/composites/composites_internal.hxx
@@ -57,7 +57,7 @@ public:
 	}
 
 	auto size(void) const -> std::size_t {
-		return composites.size();
+		return all_composites.size();
 	}
 
 	auto find(std::string_view name) const -> const rspamd_composite * {
diff --git a/src/libserver/composites/composites_manager.cxx b/src/libserver/composites/composites_manager.cxx
index c2e719c89..cf91d1136 100644
--- a/src/libserver/composites/composites_manager.cxx
+++ b/src/libserver/composites/composites_manager.cxx
@@ -87,7 +87,7 @@ composites_manager::add_composite(std::string_view composite_name, const ucl_obj
 
 	auto &composite = all_composites.emplace_back(std::make_shared<rspamd_composite>());
 	composite->expr = expr;
-	composite->id = all_composites.size();
+	composite->id = all_composites.size() - 1;
 	composite->str_expr = composite_expression;
 	composite->sym = composite_name;
 


More information about the Commits mailing list