@@ -241,6 +241,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
241
241
}
242
242
}
243
243
nheader = i + 1 ;
244
+ if (nheader < 1 ) {nheader = 1 ;}
244
245
xdifile -> meta_families = calloc (nheader , sizeof (char * ));
245
246
xdifile -> meta_keywords = calloc (nheader , sizeof (char * ));
246
247
xdifile -> meta_values = calloc (nheader , sizeof (char * ));
@@ -410,6 +411,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
410
411
npts_ = ilen - nheader + 1 ;
411
412
412
413
nouter = npts_ - 1 ;
414
+ if (nouter < 1 ) {nouter = 1 ;}
413
415
outer_arr = calloc (nouter , sizeof (double ));
414
416
outer_pts = calloc (nouter , sizeof (long ));
415
417
outer_arr [0 ] = outer_arr0 ;
@@ -422,7 +424,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
422
424
COPY_STRING (xdifile -> filename , filename );
423
425
424
426
maxcol ++ ;
425
-
427
+ if ( ncols < 1 ) { ncols = 1 ;}
426
428
xdifile -> array_labels = calloc (ncols , sizeof (char * ));
427
429
xdifile -> array_units = calloc (ncols , sizeof (char * ));
428
430
has_energy = 0 ;
@@ -446,6 +448,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
446
448
447
449
/* set size of data arrays */
448
450
xdifile -> array = calloc (ncols , sizeof (double * ));
451
+ if (npts_ < 0 ) {npts_ = 0 ;}
449
452
for (j = 0 ; j < ncols ; j ++ ) {
450
453
xdifile -> array [j ] = calloc (npts_ + 1 , sizeof (double ));
451
454
if (0 != xdi_strtod (words [j ], & dval )) {
@@ -546,6 +549,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
546
549
xdifile -> narrays = ncols ;
547
550
xdifile -> narray_labels = min (ncols , maxcol );
548
551
xdifile -> nmetadata = ndict + 1 ;
552
+ if (iouter < 1 ) {iouter = 1 ;}
549
553
xdifile -> outer_array = calloc (iouter , sizeof (double ));
550
554
xdifile -> outer_breakpts = calloc (iouter , sizeof (long ));
551
555
for (j = 0 ; j < iouter ; j ++ ) {
0 commit comments