Skip to content

Commit

Permalink
RAII: LTRResultIterator::GetUTF8Text
Browse files Browse the repository at this point in the history
  • Loading branch information
rfschtkt committed May 11, 2017
1 parent f75665c commit 2772f78
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ char* TessBaseAPI::GetBoxText(int page_number) {
do {
int left, top, right, bottom;
if (it->BoundingBox(RIL_SYMBOL, &left, &top, &right, &bottom)) {
char* text = it->GetUTF8Text(RIL_SYMBOL);
const std::unique_ptr</*non-const*/ char[]> text(it->GetUTF8Text(RIL_SYMBOL));
// Tesseract uses space for recognition failure. Fix to a reject
// character, kTesseractReject so we don't create illegal box files.
for (int i = 0; text[i] != '\0'; ++i) {
Expand All @@ -1726,10 +1726,9 @@ char* TessBaseAPI::GetBoxText(int page_number) {
}
snprintf(result + output_length, total_length - output_length,
"%s %d %d %d %d %d\n",
text, left, image_height_ - bottom,
text.get(), left, image_height_ - bottom,
right, image_height_ - top, page_number);
output_length += strlen(result + output_length);
delete [] text;
// Just in case...
if (output_length + kMaxBytesPerLine > total_length)
break;
Expand Down

0 comments on commit 2772f78

Please sign in to comment.