Skip to content

Commit

Permalink
Fix CID 1164570 (Dereference after null check) (#1333)
Browse files Browse the repository at this point in the history
Show a warning if datapath_ is NULL instead of crashing.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil authored and zdenop committed Feb 21, 2018
1 parent 6a58b2e commit eb8a6a5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2287,9 +2287,15 @@ int TessBaseAPI::FindLines() {
} else {
osd_tesseract_ = new Tesseract;
TessdataManager mgr(reader_);
if (osd_tesseract_->init_tesseract(datapath_->string(), nullptr, "osd",
OEM_TESSERACT_ONLY, nullptr, 0,
nullptr, nullptr, false, &mgr) == 0) {
if (datapath_ == nullptr) {
tprintf("Warning: Auto orientation and script detection requested,"
" but data path is undefined\n");
delete osd_tesseract_;
osd_tesseract_ = nullptr;
} else if (osd_tesseract_->init_tesseract(datapath_->string(), nullptr,
"osd", OEM_TESSERACT_ONLY,
nullptr, 0, nullptr, nullptr,
false, &mgr) == 0) {
osd_tess = osd_tesseract_;
osd_tesseract_->set_source_resolution(
thresholder_->GetSourceYResolution());
Expand Down

0 comments on commit eb8a6a5

Please sign in to comment.