Skip to content

Commit 09976e6

Browse files
committed
Fix CID 1393238 (Dereference null return value)
Add also some error handling if fopen fails. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 27a5908 commit 09976e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ccmain/control.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ bool Tesseract::ProcessTargetWord(const TBOX& word_box,
128128
if (backup_config_file_ == nullptr) {
129129
backup_config_file_ = kBackUpConfigFile;
130130
FILE* config_fp = fopen(backup_config_file_, "wb");
131-
ParamUtils::PrintParams(config_fp, params());
132-
fclose(config_fp);
131+
if (config_fp == nullptr) {
132+
tprintf("Error, failed to open file \"%s\"\n", backup_config_file_);
133+
} else {
134+
ParamUtils::PrintParams(config_fp, params());
135+
fclose(config_fp);
136+
}
133137
ParamUtils::ReadParamsFile(word_config,
134138
SET_PARAM_CONSTRAINT_DEBUG_ONLY,
135139
params());

0 commit comments

Comments
 (0)