From 1569e5080810f4652b720bcd344026a9b236ec50 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 24 Mar 2023 15:50:47 +0100 Subject: [PATCH] textord: Catch empty rows in block iterator (fixes #4039) When textord_blockndoc_fixed was set to 1 empty rows caused a segmentation fault. Test also textord_blockndoc_fixed first because it is typically 0. Signed-off-by: Stefan Weil --- src/textord/topitch.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/textord/topitch.cpp b/src/textord/topitch.cpp index 0d01e93fd7..15fe23b8c5 100644 --- a/src/textord/topitch.cpp +++ b/src/textord/topitch.cpp @@ -398,9 +398,8 @@ bool try_doc_fixed( // determine pitch int16_t mid_cuts; // no of cheap cuts float pitch_sd; // sync rating - if (block_it.empty() - // || block_it.data()==block_it.data_relative(1) - || !textord_blockndoc_fixed) { + if (!textord_blockndoc_fixed || + block_it.empty() || block_it.data()->get_rows()->empty()) { return false; } shift_factor = gradient / (gradient * gradient + 1);