check int range
This commit is contained in:
parent
dd094c317d
commit
068cf2322c
|
@ -686,8 +686,10 @@ printf("Nc=%d\n",Nc);
|
||||||
memset(buf,0,buff_len);
|
memset(buf,0,buff_len);
|
||||||
c=read_next_string(&buf,&buff_len,cfp);
|
c=read_next_string(&buf,&buff_len,cfp);
|
||||||
if (c!=1) {
|
if (c!=1) {
|
||||||
/* first column is solution number (int) 1..8N */
|
/* first column is solution number (int) 0..8N-1 */
|
||||||
sscanf(buf,"%d",&cn);
|
sscanf(buf,"%d",&cn);
|
||||||
|
/* also do a sanity check */
|
||||||
|
if ( cn<0 || cn>Nc ) cn=0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%d ",cn);
|
printf("%d ",cn);
|
||||||
|
|
Loading…
Reference in New Issue