Skip to content

Commit

Permalink
Fix duplicate fclose
Browse files Browse the repository at this point in the history
Coverity bug report: CID 1270401 (#1 of 1): Use after free

As the comment (which was also fixed) says, ReadNextBox() already
calls fclose(box_file), so don't call it a 2nd time.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 25, 2015
1 parent 62ae99c commit 9f87c36
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions ccmain/recogtraining.cpp
Expand Up @@ -84,7 +84,7 @@ void Tesseract::recog_training_segmented(const STRING &fname,
const char *lastdot = strrchr(box_fname.string(), '.');
if (lastdot != NULL) box_fname[lastdot - box_fname.string()] = '\0';
box_fname += ".box";
// read_next_box() will close box_file
// ReadNextBox() will close box_file
FILE *box_file = open_file(box_fname.string(), "r");

PAGE_RES_IT page_res_it;
Expand Down Expand Up @@ -132,7 +132,6 @@ void Tesseract::recog_training_segmented(const STRING &fname,
}
page_res_it.forward();
} while (keep_going);
fclose(box_file);

// Set up scripts on all of the words that did not get sent to
// ambigs_classify_and_output. They all should have, but if all the
Expand Down

0 comments on commit 9f87c36

Please sign in to comment.