]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Set loaded variable explicitly
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 13 Nov 2023 13:03:49 +0000 (13:03 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 13 Nov 2023 13:04:40 +0000 (13:04 +0000)
src/libmime/lang_detection_fasttext.cxx

index a1490fc1113ecd5547190a9202bd95dd49fed53c..c973ed710f7f75d48b21810f6772211533fd2e6a 100644 (file)
@@ -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,