Skip to content

Commit

Permalink
Fix crash if output file could not be opened
Browse files Browse the repository at this point in the history
This error case results in fout_ == nullptr.
Closing a nullptr file is not allowed.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed May 13, 2017
1 parent 5ffd469 commit f1e6f44
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions api/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ TessResultRenderer::TessResultRenderer(const char *outputbase,
}

TessResultRenderer::~TessResultRenderer() {
if (fout_ != stdout)
fclose(fout_);
else
clearerr(fout_);
if (fout_ != nullptr) {
if (fout_ != stdout)
fclose(fout_);
else
clearerr(fout_);
}
delete next_;
}

Expand Down

0 comments on commit f1e6f44

Please sign in to comment.