Skip to content

Commit

Permalink
Fix CID 1393238 (Dereference null return value)
Browse files Browse the repository at this point in the history
Add also some error handling if fopen fails.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jun 20, 2018
1 parent 27a5908 commit 09976e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ bool Tesseract::ProcessTargetWord(const TBOX& word_box,
if (backup_config_file_ == nullptr) {
backup_config_file_ = kBackUpConfigFile;
FILE* config_fp = fopen(backup_config_file_, "wb");
ParamUtils::PrintParams(config_fp, params());
fclose(config_fp);
if (config_fp == nullptr) {
tprintf("Error, failed to open file \"%s\"\n", backup_config_file_);
} else {
ParamUtils::PrintParams(config_fp, params());
fclose(config_fp);
}
ParamUtils::ReadParamsFile(word_config,
SET_PARAM_CONSTRAINT_DEBUG_ONLY,
params());
Expand Down

0 comments on commit 09976e6

Please sign in to comment.