From 4fc08b4c95d2794db812fee86bc5ea35a36a20f0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 13 Nov 2023 13:03:49 +0000 Subject: [PATCH] [Fix] Set loaded variable explicitly --- src/libmime/lang_detection_fasttext.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libmime/lang_detection_fasttext.cxx b/src/libmime/lang_detection_fasttext.cxx index a1490fc11..c973ed710 100644 --- a/src/libmime/lang_detection_fasttext.cxx +++ b/src/libmime/lang_detection_fasttext.cxx @@ -40,7 +40,7 @@ class fasttext_langdet { private: fasttext::FastText ft; std::string model_fname; - bool loaded; + bool loaded = false; public: explicit fasttext_langdet(struct rspamd_config *cfg) @@ -124,10 +124,11 @@ public: return predictions; } - auto model_info(void) const -> std::string + auto model_info(void) const -> const std::string { if (!loaded) { - return "fasttext model is not loaded"; + static const auto not_loaded = std::string{"fasttext model is not loaded"}; + return not_loaded; } else { return fmt::format("fasttext model {}: {} languages, {} tokens", model_fname, -- 2.39.5