--- ray/src/util/rmatrix.c 2014/05/31 19:21:21 2.2 +++ ray/src/util/rmatrix.c 2014/07/24 16:28:17 2.4 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rmatrix.c,v 2.2 2014/05/31 19:21:21 greg Exp $"; +static const char RCSid[] = "$Id: rmatrix.c,v 2.4 2014/07/24 16:28:17 greg Exp $"; #endif /* * General matrix operations. @@ -173,16 +173,22 @@ rmx_load(const char *fname) #endif dinfo.nrows = dinfo.ncols = dinfo.ncomp = 0; dinfo.dtype = DTascii; - if (getheader(fp, &get_dminfo, &dinfo) < 0) { + if (getheader(fp, get_dminfo, &dinfo) < 0) { fclose(fp); return(NULL); } - if ((dinfo.dtype == DTrgbe) | (dinfo.dtype == DTxyze)) { + if ((dinfo.nrows <= 0) | (dinfo.ncols <= 0)) { if (!fscnresolu(&dinfo.ncols, &dinfo.nrows, fp)) { fclose(fp); return(NULL); } - dinfo.ncomp = 3; + if (dinfo.ncomp <= 0) + dinfo.ncomp = 3; + else if ((dinfo.dtype == DTrgbe) | (dinfo.dtype == DTxyze) && + dinfo.ncomp != 3) { + fclose(fp); + return(NULL); + } } dnew = rmx_alloc(dinfo.nrows, dinfo.ncols, dinfo.ncomp); if (dnew == NULL) {