Index: var.c =================================================================== RCS file: /upc/share/CVS/netcdf-3/libsrc/var.c,v retrieving revision 1.128 retrieving revision 1.129 diff -c -r1.128 -r1.129 *** var.c 30 Sep 2004 18:47:12 -0000 1.128 --- var.c 6 Mar 2008 21:05:02 -0000 1.129 *************** *** 2,8 **** * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. */ ! /* $Id: var.c,v 1.128 2004/09/30 18:47:12 russ Exp $ */ #include "nc.h" #include --- 2,8 ---- * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. */ ! /* $Id: var.c,v 1.129 2008/03/06 21:05:02 russ Exp $ */ #include "nc.h" #include *************** *** 397,429 **** shp--, dsp--) { if(!(shp == varp->shape && IS_RECVAR(varp))) ! product *= *shp; *dsp = product; } out : ! if( varp->xsz <= X_UINT_MAX / product ) /* if integer multiply will not overflow */ { varp->len = product * varp->xsz; } else { /* OK for last var to be "too big", indicated by this special len */ varp->len = X_UINT_MAX; } - switch(varp->type) { - case NC_BYTE : - case NC_CHAR : - case NC_SHORT : - if( varp->len%4 != 0 ) - { - varp->len += 4 - varp->len%4; /* round up */ - /* *dsp += 4 - *dsp%4; */ - } - break; - default: - /* already aligned */ - break; - } #if 0 arrayp("\tshape", varp->ndims, varp->shape); arrayp("\tdsizes", varp->ndims, varp->dsizes); --- 397,437 ---- shp--, dsp--) { if(!(shp == varp->shape && IS_RECVAR(varp))) ! { ! if( *shp <= X_UINT_MAX / product ) ! { ! product *= *shp; ! } else ! { ! product = X_UINT_MAX ; ! } ! } *dsp = product; } out : ! if( varp->xsz <= (X_UINT_MAX - 1) / product ) /* if integer multiply will not overflow */ { varp->len = product * varp->xsz; + switch(varp->type) { + case NC_BYTE : + case NC_CHAR : + case NC_SHORT : + if( varp->len%4 != 0 ) + { + varp->len += 4 - varp->len%4; /* round up */ + /* *dsp += 4 - *dsp%4; */ + } + break; + default: + /* already aligned */ + break; + } } else { /* OK for last var to be "too big", indicated by this special len */ varp->len = X_UINT_MAX; } #if 0 arrayp("\tshape", varp->ndims, varp->shape); arrayp("\tdsizes", varp->ndims, varp->dsizes);