From ac67494431c289d6eb44cdadc396741ce83b88d7 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Fri, 30 Nov 2012 15:17:32 +0300 Subject: [PATCH] Fix crash in gen_initial_maps() If image is too small some coordinates can became negative, handle it properly to avoid memory corruption --- libfprint/nbis/mindtct/maps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libfprint/nbis/mindtct/maps.c b/libfprint/nbis/mindtct/maps.c index 6f49e3c..4c0bb4e 100644 --- a/libfprint/nbis/mindtct/maps.c +++ b/libfprint/nbis/mindtct/maps.c @@ -307,6 +307,12 @@ int gen_initial_maps(int **odmap, int **olcmap, int **olfmap, xmaxlimit = pw - dftgrids->pad - lfsparms->windowsize - 1; ymaxlimit = ph - dftgrids->pad - lfsparms->windowsize - 1; + /* max limits should not be negative */ + if (xmaxlimit < 0) + xmaxlimit = 0; + if (ymaxlimit < 0) + ymaxlimit = 0; + /* Foreach block in image ... */ for(bi = 0; bi < bsize; bi++){ /* Adjust block offset from pointing to block origin to pointing */ -- 1.8.0.1