From 06e11d447383a44478ed105a199cd441832c7146 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Mon, 25 Mar 2024 13:36:04 -0400 Subject: [PATCH] Prevent integer overflow for large grid files --- source/gwb-grid/main.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/gwb-grid/main.cc b/source/gwb-grid/main.cc index c17798404..78181b757 100644 --- a/source/gwb-grid/main.cc +++ b/source/gwb-grid/main.cc @@ -1519,33 +1519,33 @@ int main(int argc, char **argv) if (dim == 2) for (size_t i = 0; i < n_cell; ++i) { - connectivity[i*pow_2_dim] = static_cast(grid_connectivity[i][0]); - connectivity[i*pow_2_dim+1] = static_cast(grid_connectivity[i][1]); - connectivity[i*pow_2_dim+2] = static_cast(grid_connectivity[i][2]); - connectivity[i*pow_2_dim+3] = static_cast(grid_connectivity[i][3]); + connectivity[i*pow_2_dim] = static_cast(grid_connectivity[i][0]); + connectivity[i*pow_2_dim+1] = static_cast(grid_connectivity[i][1]); + connectivity[i*pow_2_dim+2] = static_cast(grid_connectivity[i][2]); + connectivity[i*pow_2_dim+3] = static_cast(grid_connectivity[i][3]); } else for (size_t i = 0; i < n_cell; ++i) { - connectivity[i*pow_2_dim] = static_cast(grid_connectivity[i][0]); - connectivity[i*pow_2_dim+1] = static_cast(grid_connectivity[i][1]); - connectivity[i*pow_2_dim+2] = static_cast(grid_connectivity[i][2]); - connectivity[i*pow_2_dim+3] = static_cast(grid_connectivity[i][3]); - connectivity[i*pow_2_dim+4] = static_cast(grid_connectivity[i][4]); - connectivity[i*pow_2_dim+5] = static_cast(grid_connectivity[i][5]); - connectivity[i*pow_2_dim+6] = static_cast(grid_connectivity[i][6]); - connectivity[i*pow_2_dim+7] = static_cast(grid_connectivity[i][7]); + connectivity[i*pow_2_dim] = static_cast(grid_connectivity[i][0]); + connectivity[i*pow_2_dim+1] = static_cast(grid_connectivity[i][1]); + connectivity[i*pow_2_dim+2] = static_cast(grid_connectivity[i][2]); + connectivity[i*pow_2_dim+3] = static_cast(grid_connectivity[i][3]); + connectivity[i*pow_2_dim+4] = static_cast(grid_connectivity[i][4]); + connectivity[i*pow_2_dim+5] = static_cast(grid_connectivity[i][5]); + connectivity[i*pow_2_dim+6] = static_cast(grid_connectivity[i][6]); + connectivity[i*pow_2_dim+7] = static_cast(grid_connectivity[i][7]); } std::cout << "[5/6] Preparing to write the paraview file: stage 3 of 6, creating the offsets \r"; std::cout.flush(); std::vector offsets(n_cell); if (dim == 2) for (size_t i = 0; i < n_cell; ++i) - offsets[i] = static_cast((i+1) * 4); + offsets[i] = static_cast((i+1) * 4); else for (size_t i = 0; i < n_cell; ++i) - offsets[i] = static_cast((i+1) * 8); + offsets[i] = static_cast((i+1) * 8); std::cout << "[5/6] Preparing to write the paraview file: stage 4 of 6, creating the Data set info \r"; std::cout.flush();