Skip to content

Commit 5812972

Browse files
committed
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>
1 parent cd58a86 commit 5812972

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/textord/scanedg.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void block_edges(Pix *t_pix, // thresholded image
5050
CRACKEDGE *free_cracks = nullptr;
5151

5252
block->bounding_box(bleft, tright); // block box
53+
ASSERT_HOST(tright.x() <= width);
54+
ASSERT_HOST(tright.y() <= height);
5355
int block_width = tright.x() - bleft.x();
5456
for (int x = block_width; x >= 0; x--)
5557
ptrline[x] = nullptr; // no lines in progress

0 commit comments

Comments
 (0)