Fix use of position variables with plus/merge
authorTeemu Murtola <teemu.murtola@gmail.com>
Mon, 5 Dec 2016 19:26:27 +0000 (21:26 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 7 Dec 2016 01:03:01 +0000 (02:03 +0100)
commitc848f4a4b18eed9cd36d97a59d5d97f0cdd5ad4e
tree3bcb23d29bdeadee8064c8ce032704d0bc1f7baa
parente8a1370403a41ab749e2f31ebbdc7b8472b7135d
Fix use of position variables with plus/merge

If a selection contained a position variable (e.g., 'com of ...') that
was used more than once, and at least one of those uses was with
plus/merge, there were out-of-bounds memory writes.  This was caused by
the internal position structure not getting fully initialized.
Incomplete initialization happens in all contexts with such variables,
but only plus/merge (and possibly permute) actually use the values that
remained uninitialized, which caused them to incorrectly compute the
amount of memory required to store the result.

Fixes part of #2086.

Change-Id: I016e796db268a11d557309935c02cbd1bc79a83c
src/gromacs/selection/compiler.cpp
src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionVariableInModifier.xml [new file with mode: 0644]
src/gromacs/selection/tests/selectioncollection.cpp