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

Comparing ray/src/util/cmatrix.c (file contents):
Revision 2.27 by greg, Thu Mar 26 16:56:10 2020 UTC vs.
Revision 2.29 by greg, Fri Jan 15 02:46:28 2021 UTC

# Line 33 | Line 33 | cm_alloc(int nrows, int ncols)
33          if ((nrows <= 0) | (ncols <= 0))
34                  error(USER, "attempt to create empty matrix");
35          cm = (CMATRIX *)malloc(sizeof(CMATRIX) +
36 <                                sizeof(COLOR)*(nrows*ncols - 1));
36 >                                sizeof(COLOR)*((size_t)nrows*ncols - 1));
37          if (!cm)
38                  error(SYSTEM, "out of memory in cm_alloc()");
39          cm->nrows = nrows;
# Line 181 | Line 181 | cm_load_rgbe(FILE *fp, int nrows, int ncols, COLOR sca
181          CMATRIX *cm;
182          COLORV  *mp;
183                                                  /* header already loaded */
184        if ((nrows <= 0) | (ncols <= 0) && !fscnresolu(&ncols, &nrows, fp)) {
185                error(USER, "bad picture resolution string");
186                return(NULL);
187        }
184          cm = cm_alloc(nrows, ncols);
185          if (!cm)
186                  return(NULL);
# Line 242 | Line 238 | cm_load(const char *inspec, int nrows, int ncols, int
238                  char    *err = cm_getheader(&dtype, &nrows, &ncols, &swap, scale, fp);
239                  if (err)
240                          error(USER, err);
245                if (ncols <= 0)
246                        error(USER, "unspecified number of columns");
241          }
242 +        if (ncols <= 0 && !fscnresolu(&ncols, &nrows, fp))
243 +                error(USER, "unspecified number of columns");
244          switch (dtype) {
245          case DTascii:
246          case DTfloat:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines