check int range

This commit is contained in:
Sarod Yatawatta 2018-02-27 16:15:23 +01:00
parent dd094c317d
commit 068cf2322c
1 changed files with 3 additions and 1 deletions

View File

@ -686,8 +686,10 @@ printf("Nc=%d\n",Nc);
memset(buf,0,buff_len);
c=read_next_string(&buf,&buff_len,cfp);
if (c!=1) {
/* first column is solution number (int) 1..8N */
/* first column is solution number (int) 0..8N-1 */
sscanf(buf,"%d",&cn);
/* also do a sanity check */
if ( cn<0 || cn>Nc ) cn=0;
}
#ifdef DEBUG
printf("%d ",cn);