commit b661260: [Fix] Set loaded variable explicitly

Vsevolod Stakhov vsevolod at rspamd.com
Mon Nov 13 13:07:03 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-11-13 13:03:49 +0000
URL: https://github.com/rspamd/rspamd/commit/b6612604aa2b06ef7b12c2aaf24a4175dcea67e5 (HEAD -> master)

[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,


More information about the Commits mailing list