From 93878e8816bcd2e292a420ba5b262d9ca2818a6f Mon Sep 17 00:00:00 2001 From: Russ Rew Date: Thu, 27 Feb 2014 12:19:14 -0700 Subject: [PATCH] Fix possibility of divide by zero in rechunking. --- RELEASE_NOTES.md | 2 +- libsrc4/nc4var.c | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b57315a0a..9318df7eb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,7 +7,7 @@ This file contains a high-level description of this package's evolution. Release ## 4.3.1.2 Released TBD -* Fixed small default chunk size for 1-dimensional record variables. +* Fixed small default chunk size for 1-dimensional record variables. [NCF-211](https://bugtracking.unidata.ucar.edu/browse/NCF-211) * Cleaned up type handling in netCDF-4 to fix bugs with fill-values. diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 1dd770880..4a64cb102 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -235,11 +235,10 @@ static int nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) { int d; - size_t type_size, max_len = 0; + size_t type_size; float num_values = 1, num_set = 0; int retval; #ifdef LOGGING - int max_dim; double total_chunk_size; #endif @@ -260,20 +259,10 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) for (d = 0; d < var->ndims; d++) { assert(var->dim[d]); - if (var->dim[d]->len) + if (var->dim[d]->len > 0) num_values *= (float)var->dim[d]->len; else num_set++; - - if (var->dim[d]->len > max_len) - { - max_len = var->dim[d]->len; -#ifdef LOGGING - max_dim = d; -#endif - } - LOG((4, "d = %d max_dim %d max_len %ld num_values %f", d, max_dim, max_len, - num_values)); } /* Pick a chunk length for each dimension, if one has not already