From 1d8626c6c1635afb7d61c18924e06da65cd51089 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 11 Dec 2022 22:25:59 +0100 Subject: [PATCH] Fix function tesseract::write_set (issue #3965) It crashed when running mftraining with fs.size() == 0. Signed-off-by: Stefan Weil --- src/ccstruct/fontinfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ccstruct/fontinfo.cpp b/src/ccstruct/fontinfo.cpp index 9395ebfb8a..65d4d032e1 100644 --- a/src/ccstruct/fontinfo.cpp +++ b/src/ccstruct/fontinfo.cpp @@ -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.