Skip to content

Commit 2ec6c18

Browse files
committed
Fix floating point exception caused by multiplication overflow turning to zero in prod variable
1 parent 356b31d commit 2ec6c18

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libsrc/var.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ NC_var_shape(NC_var *varp, const NC_dimarray *dims)
485485
/*if(!(shp == varp->shape && IS_RECVAR(varp)))*/
486486
if( shp != NULL && (shp != varp->shape || !IS_RECVAR(varp)))
487487
{
488+
if(product <= 0)
489+
return NC_ERANGE;
488490
if( ((off_t)(*shp)) <= OFF_T_MAX / product )
489491
{
490492
product *= (*shp > 0 ? (off_t)*shp : 1);

0 commit comments

Comments
 (0)