block_edges: Add assertions for block coordinates

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>
This commit is contained in:
Stefan Weil 2018-06-09 13:52:25 +02:00
parent cd58a861d9
commit 5812972775

View File

@ -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