mindtct: Check for multiplication overflow in gen_high_curve_map()

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

Closes: #101
This commit is contained in:
Bastien Nocera 2018-12-13 15:23:48 +01:00
parent 239034714f
commit 4fa8c5ec47

View file

@ -898,9 +898,11 @@ int gen_high_curve_map(int **ohcmap, int *direction_map,
int bx, by; int bx, by;
int nvalid, cmeasure, vmeasure; int nvalid, cmeasure, vmeasure;
ASSERT_INT_MUL(mw, mh);
mapsize = mw*mh; mapsize = mw*mh;
/* Allocate High Curvature Map. */ /* Allocate High Curvature Map. */
ASSERT_SIZE_MUL(mapsize, sizeof(int));
high_curve_map = (int *)malloc(mapsize * sizeof(int)); high_curve_map = (int *)malloc(mapsize * sizeof(int));
if(high_curve_map == (int *)NULL){ if(high_curve_map == (int *)NULL){
fprintf(stderr, fprintf(stderr,