Commit ad8c2627 authored by peastman's avatar peastman
Browse files

Fixed a rare segfault in CPU platform

parent 14cdc9ae
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2013-2015 Stanford University and the Authors. * * Portions copyright (c) 2013-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -158,8 +158,8 @@ public: ...@@ -158,8 +158,8 @@ public:
float scale1 = floorf(yperiodic*recipBoxSize[1]); float scale1 = floorf(yperiodic*recipBoxSize[1]);
yperiodic -= periodicBoxVectors[1][0]*scale1; yperiodic -= periodicBoxVectors[1][0]*scale1;
} }
int y = min(ny-1, int(floorf(yperiodic / voxelSizeY))); int y = max(0, min(ny-1, int(floorf(yperiodic / voxelSizeY))));
int z = min(nz-1, int(floorf(zperiodic / voxelSizeZ))); int z = max(0, min(nz-1, int(floorf(zperiodic / voxelSizeZ))));
return VoxelIndex(y, z); return VoxelIndex(y, z);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment