Skip to content

Commit

Permalink
block_edges: Add assertions for block coordinates
Browse files Browse the repository at this point in the history
Check whether the top right point of the block is inside of the
thresholded image t_pix. Otherwise the following code would make
illegal memory accesses.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 9, 2018
1 parent cd58a86 commit 5812972
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/textord/scanedg.cpp
Expand Up @@ -50,6 +50,8 @@ void block_edges(Pix *t_pix, // thresholded image
CRACKEDGE *free_cracks = nullptr;

block->bounding_box(bleft, tright); // block box
ASSERT_HOST(tright.x() <= width);
ASSERT_HOST(tright.y() <= height);
int block_width = tright.x() - bleft.x();
for (int x = block_width; x >= 0; x--)
ptrline[x] = nullptr; // no lines in progress
Expand Down

0 comments on commit 5812972

Please sign in to comment.