Skip to content

Commit eb8a6a5

Browse files
stweilzdenop
authored andcommitted
Fix CID 1164570 (Dereference after null check) (#1333)
Show a warning if datapath_ is NULL instead of crashing. Signed-off-by: Stefan Weil <[email protected]>
1 parent 6a58b2e commit eb8a6a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api/baseapi.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -2287,9 +2287,15 @@ int TessBaseAPI::FindLines() {
22872287
} else {
22882288
osd_tesseract_ = new Tesseract;
22892289
TessdataManager mgr(reader_);
2290-
if (osd_tesseract_->init_tesseract(datapath_->string(), nullptr, "osd",
2291-
OEM_TESSERACT_ONLY, nullptr, 0,
2292-
nullptr, nullptr, false, &mgr) == 0) {
2290+
if (datapath_ == nullptr) {
2291+
tprintf("Warning: Auto orientation and script detection requested,"
2292+
" but data path is undefined\n");
2293+
delete osd_tesseract_;
2294+
osd_tesseract_ = nullptr;
2295+
} else if (osd_tesseract_->init_tesseract(datapath_->string(), nullptr,
2296+
"osd", OEM_TESSERACT_ONLY,
2297+
nullptr, 0, nullptr, nullptr,
2298+
false, &mgr) == 0) {
22932299
osd_tess = osd_tesseract_;
22942300
osd_tesseract_->set_source_resolution(
22952301
thresholder_->GetSourceYResolution());

0 commit comments

Comments
 (0)