From 0b480294b5d60e636ed479b75305532537bbc582 Mon Sep 17 00:00:00 2001 From: Rex Zhe Li Date: Sat, 29 Aug 2020 12:22:20 -0400 Subject: [PATCH] fix spill of integer index in AggregateLabels --- common/Domain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/Domain.cpp b/common/Domain.cpp index eadc4592..7a1a6230 100644 --- a/common/Domain.cpp +++ b/common/Domain.cpp @@ -695,7 +695,7 @@ void Domain::AggregateLabels( const std::string& filename ){ int full_ny = npy*(ny-2); int full_nz = npz*(nz-2); int local_size = (nx-2)*(ny-2)*(nz-2); - long int full_size = long(full_nx)*long(full_ny)*long(full_nz); + unsigned long int full_size = long(full_nx)*long(full_ny)*long(full_nz); signed char *LocalID; LocalID = new signed char [local_size]; @@ -725,7 +725,7 @@ void Domain::AggregateLabels( const std::string& filename ){ int y = j-1; int z = k-1; int n_local = (k-1)*(nx-2)*(ny-2) + (j-1)*(nx-2) + i-1; - int n_full = z*full_nx*full_ny + y*full_nx + x; + unsigned long int n_full = z*long(full_nx)*long(full_ny) + y*long(full_nx) + x; FullID[n_full] = LocalID[n_local]; } } @@ -745,7 +745,7 @@ void Domain::AggregateLabels( const std::string& filename ){ int y = j-1 + ipy*(ny-2); int z = k-1 + ipz*(nz-2); int n_local = (k-1)*(nx-2)*(ny-2) + (j-1)*(nx-2) + i-1; - int n_full = z*full_nx*full_ny + y*full_nx + x; + unsigned long int n_full = z*long(full_nx)*long(full_ny) + y*long(full_nx) + x; FullID[n_full] = LocalID[n_local]; } }