Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d61bbb3

Browse files
committed
Better check of input data?
1 parent 58b38cc commit d61bbb3

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

Demo/sgi/video/squash.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,19 @@ main(argc, argv)
7878
exit(1);
7979
}
8080
while( !feof(stdin) ) {
81-
gets(lbuf);
82-
if ( feof(stdin) ) break;
83-
puts(lbuf);
81+
{ int t, s;
82+
gets(lbuf);
83+
if ( feof(stdin) ) break;
84+
if ( sscanf(lbuf, "%d,%d", &t,&s) == 2) {
85+
if ( s != h*w*4 ) {
86+
fprintf(stderr, "Size changed from %d to %d: %s\n",4*h*w,s, lbuf);
87+
exit(1);
88+
}
89+
printf("%d, %d\n", t, nh*nw*4);
90+
} else {
91+
puts(lbuf);
92+
}
93+
}
8494
fprintf(stderr, "Reading %d\n", h*w*sizeof(long));
8595
if ( (i=fread(bm, 1, h*w*sizeof(long), stdin)) != h*w*sizeof(long)) {
8696
fprintf(stderr, "%s: short read, %d wanted %d\n", argv[0],

0 commit comments

Comments
 (0)