Skip to content

Commit 356b31d

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

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
@@ -533,6 +533,8 @@ NC_check_vlen(NC_var *varp, long long vlen_max) {
533533
for(ii = IS_RECVAR(varp) ? 1 : 0; ii < varp->ndims; ii++) {
534534
if(!varp->shape)
535535
return 0; /* Shape is undefined/NULL. */
536+
if(prod <= 0)
537+
return 0; /* Multiplication operations may result in overflow */
536538
if ((long long)varp->shape[ii] > vlen_max / prod) {
537539
return 0; /* size in bytes won't fit in a 32-bit int */
538540
}

0 commit comments

Comments
 (0)