Skip to content

Commit

Permalink
textord: Catch empty rows in block iterator (fixes #4039)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stweil committed Mar 24, 2023
1 parent 691de2b commit 1569e50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/textord/topitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1569e50

Please sign in to comment.