mindtct: Check for multiplication overflow in interpolate_direction_map()

Assert if any of the multiplications, which are then used to allocate
memory, would overflow.

Closes: #100
This commit is contained in:
Bastien Nocera 2018-12-13 15:25:37 +01:00
parent 4fa8c5ec47
commit 5459823667

View file

@ -502,6 +502,8 @@ int interpolate_direction_map(int *direction_map, int *low_contrast_map,
print2log("INTERPOLATE DIRECTION MAP\n"); print2log("INTERPOLATE DIRECTION MAP\n");
/* Allocate output (interpolated) Direction Map. */ /* Allocate output (interpolated) Direction Map. */
ASSERT_SIZE_MUL(mw, mh);
ASSERT_SIZE_MUL(mw * mh, sizeof(int));
omap = (int *)malloc(mw*mh*sizeof(int)); omap = (int *)malloc(mw*mh*sizeof(int));
if(omap == (int *)NULL){ if(omap == (int *)NULL){
fprintf(stderr, fprintf(stderr,