ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/genprism.c
(Generate patch)

Comparing ray/src/gen/genprism.c (file contents):
Revision 2.4 by greg, Mon Aug 2 14:23:04 1993 UTC vs.
Revision 2.5 by greg, Thu Feb 22 14:38:51 1996 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *              command line or from a file.  Their order together
11   *              with the extrude direction will determine surface
12   *              orientation.
13 *
14 *     8/24/87
13   */
14  
15   #include  <stdio.h>
# Line 55 | Line 53 | char  **argv;
53                  an = 4;
54          } else if (isdigit(argv[3][0])) {
55                  nverts = atoi(argv[3]);
56 +                if (nverts > MAXVERT) {
57 +                        fprintf(stderr, "%s: too many vertices (%d limit)\n",
58 +                                        argv[0], MAXVERT);
59 +                        exit(1);
60 +                }
61                  if (argc-3 < 2*nverts)
62                          goto userr;
63                  for (an = 0; an < nverts; an++) {
# Line 111 | Line 114 | char  *fname;
114   {
115          FILE  *fp;
116  
117 <        if (fname == NULL)
117 >        if (fname == NULL) {
118                  fp = stdin;
119 <        else if ((fp = fopen(fname, "r")) == NULL) {
119 >                fname = "<stdin>";
120 >        } else if ((fp = fopen(fname, "r")) == NULL) {
121                  fprintf(stderr, "%s: cannot open\n", fname);
122                  exit(1);
123          }
124          while (fscanf(fp, "%lf %lf", &vert[nverts][0], &vert[nverts][1]) == 2)
125 <                nverts++;
125 >                if (++nverts >= MAXVERT) {
126 >                        fprintf(stderr, "%s: too many vertices (%d limit)\n",
127 >                                        fname, MAXVERT-1);
128 >                        exit(1);
129 >                }
130          fclose(fp);
131   }
132  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines