diff --git a/api/baseapi.cpp b/api/baseapi.cpp index 96ac910f2f..1a730027ac 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -851,6 +851,9 @@ int TessBaseAPI::Recognize(ETEXT_DESC* monitor) { page_res_ = new PAGE_RES(false, block_list_, &tesseract_->prev_word_best_choice_); } + if (page_res_ == NULL) { + return -1; + } if (tesseract_->tessedit_make_boxes_from_boxes) { tesseract_->CorrectClassifyWords(page_res_); return 0;