Fix UB vector usage
authorRoland Schulz <roland.schulz@intel.com>
Tue, 26 Mar 2019 00:24:39 +0000 (17:24 -0700)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 28 Mar 2019 10:10:17 +0000 (11:10 +0100)
commit644376570e25763fcc720c704cf2b30f38ee9595
tree4105657f74dee38bb1daa966db66e16de6b589b4
parentbd00f5b2ee8f2045333e1c94475e337ce19429f8
Fix UB vector usage

It is UB to
- increment past end.
- decrement end iterator for empty vector.
- use operator[] on end iterator.

Also fixes a buffer overflow for c_simdBestPairAlignment=2.

All found with _LIBCPP_DEBUG=1.

Change-Id: Ib21ca875244673b27748a01373e7fc10252a7c44
src/gromacs/gmxpreprocess/resall.cpp
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/nbnxm/atomdata.cpp