From 8f86665abfe116f05b540e063e3c3a94aa896c4e Mon Sep 17 00:00:00 2001 From: Zhenjia Xu Date: Thu, 11 Jun 2020 16:14:05 +0800 Subject: [PATCH] fix index range Since it is 0-base, the illegal voxel_idx should be in [0, vol_dim_x*vol_dim_y*vol_dim_z). This bug may lead to "illegal memory access" --- fusion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fusion.py b/fusion.py index 9cdae72..7d8173a 100644 --- a/fusion.py +++ b/fusion.py @@ -83,7 +83,7 @@ def __init__(self, vol_bnds, voxel_size, use_gpu=True): int vol_dim_x = (int) vol_dim[0]; int vol_dim_y = (int) vol_dim[1]; int vol_dim_z = (int) vol_dim[2]; - if (voxel_idx > vol_dim_x*vol_dim_y*vol_dim_z) + if (voxel_idx >= vol_dim_x*vol_dim_y*vol_dim_z) return; // Get voxel grid coordinates (note: be careful when casting) float voxel_x = floorf(((float)voxel_idx)/((float)(vol_dim_y*vol_dim_z)));