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

Comparing ray/src/util/rmatrix.c (file contents):
Revision 2.83 by greg, Tue Oct 8 00:43:57 2024 UTC vs.
Revision 2.85 by greg, Mon Mar 24 18:55:57 2025 UTC

# Line 378 | Line 378 | rmx_load(const char *inspec, RMPref rmp)
378                  fp = stdin;
379          else if (inspec[0] == '!')
380                  fp = popen(inspec+1, "r");
381 <        else {
382 <                const char      *sp = inspec;   /* check suffix */
383 <                while (*sp)
384 <                        ++sp;
385 <                while (sp > inspec && sp[-1] != '.')
386 <                        --sp;
387 <                if (!strcasecmp(sp, "XML")) {   /* assume it's a BSDF */
381 >        else {                                  /* check suffix */
382 >                const char      *sp = strrchr(inspec, '.');
383 >                if (sp > inspec && !strcasecmp(sp+1, "XML")) {  /* BSDF? */
384                          CMATRIX *cm = rmp==RMPnone ? (CMATRIX *)NULL :
385                                          rmp==RMPtrans ? cm_loadBTDF(inspec) :
386                                          cm_loadBRDF(inspec, rmp==RMPreflB) ;
# Line 502 | Line 498 | rmx_write_spec(const rmx_dtype *dp, int nc, int len, F
498          SCOLOR  scol;
499          int     j, k;
500  
501 <        if (nc < 3) return(0);
501 >        if ((nc < 3) | (nc > MAXCSAMP)) return(0);
502          scan = (uby8 *)tempbuffer((nc+1)*len);
503          if (!scan) return(0);
504          for (j = 0; j < len; j++, dp += nc) {
# Line 948 | Line 944 | cm_from_rmatrix(const RMATRIX *rm)
944          int     i, j;
945          CMATRIX *cnew;
946  
947 <        if (!rm || !rm->mtx | (rm->ncomp == 2))
947 >        if (!rm || !rm->mtx | (rm->ncomp == 2) | (rm->ncomp > MAXCSAMP))
948                  return(NULL);
949          cnew = cm_alloc(rm->nrows, rm->ncols);
950          if (!cnew)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines