Skip to content

Commit

Permalink
Fix function tesseract::write_set (issue #3965)
Browse files Browse the repository at this point in the history
It crashed when running mftraining with fs.size() == 0.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Dec 11, 2022
1 parent 29f373c commit 1d8626c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ccstruct/fontinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ bool write_spacing_info(FILE *f, const FontInfo &fi) {

bool write_set(FILE *f, const FontSet &fs) {
int size = fs.size();
return tesseract::Serialize(f, &size) && tesseract::Serialize(f, &fs[0], size);
return tesseract::Serialize(f, &size) &&
(size > 0 ? tesseract::Serialize(f, &fs[0], size) : true);
}

} // namespace tesseract.

0 comments on commit 1d8626c

Please sign in to comment.