nbis: Fix crash in gen_initial_maps()

If the image is too small some coordinates can become negative.
Handle this to avoid memory corruption.

https://bugs.freedesktop.org/show_bug.cgi?id=57730
This commit is contained in:
Vasily Khoruzhick 2012-11-30 15:17:32 +03:00 committed by Bastien Nocera
parent 258ac2d4da
commit a7d6b7c30a

View file

@ -307,6 +307,10 @@ 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 */
xmaxlimit = MAX(xmaxlimit, 0);
ymaxlimit = MAX(ymaxlimit, 0);
/* Foreach block in image ... */
for(bi = 0; bi < bsize; bi++){
/* Adjust block offset from pointing to block origin to pointing */