From 5812972775b85f64bca69c9b092b625d828a33d2 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 9 Jun 2018 13:52:25 +0200 Subject: [PATCH] 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 --- src/textord/scanedg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/textord/scanedg.cpp b/src/textord/scanedg.cpp index bae64415a..b0fc38caa 100644 --- a/src/textord/scanedg.cpp +++ b/src/textord/scanedg.cpp @@ -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