Skip to content

Commit 7a5e5f3

Browse files
authored
Merge pull request #4563 from gaurav0107/fix/4448-crash-upon-processing-input-file-with-di
Fix crash when LSTM is missing in disabled-legacy build (#4448)
2 parents 8eeeedd + 3a3fe8d commit 7a5e5f3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎src/ccmain/tessedit.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,19 @@ bool Tesseract::init_tesseract_lang_data(const std::string &language, OcrEngineM
171171
lstm_recognizer_ = new LSTMRecognizer(language_data_path_prefix.c_str());
172172
ASSERT_HOST(lstm_recognizer_->Load(this->params(), lstm_use_matrix ? language : "", mgr));
173173
} else {
174+
#ifdef DISABLED_LEGACY_ENGINE
175+
// The legacy engine is compiled out, so we cannot fall back to it.
176+
// Returning false here propagates a load failure to init_tesseract,
177+
// which logs "Failed loading language '%s'" and skips this language.
178+
tprintf(
179+
"Error: LSTM requested, but not present in %s; the legacy "
180+
"engine is disabled in this build, so there is no fallback.\n",
181+
tessdata_path.c_str());
182+
return false;
183+
#else
174184
tprintf("Error: LSTM requested, but not present!! Loading tesseract.\n");
175185
tessedit_ocr_engine_mode.set_value(OEM_TESSERACT_ONLY);
186+
#endif // DISABLED_LEGACY_ENGINE
176187
}
177188
}
178189

0 commit comments

Comments
 (0)