Avoid crash with empty reference for 'same as' selection
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 20 May 2015 19:22:09 +0000 (22:22 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 22 May 2015 10:43:03 +0000 (12:43 +0200)
commit1cdc52e96ae0cffa45114472974122ff035e9b87
tree6dc27a28854719ca4880eecb3293657e2f7bcbf3
parent4124756a03b5d9e634d2384ae639a1732d76497a
Avoid crash with empty reference for 'same as' selection

Make 'same ... as none' selections not segfault.  If there were no atoms
in the reference group, the code that sorted the values and removed
duplicates incorrectly set the number of values as one, resulting in
incorrect memory access later.

Fixes #1742 (segfault part).

Change-Id: I9d14c30404121356ee3abf1a5575fb0baa82fb7b
src/gromacs/selection/sm_same.cpp
src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesEmptyReferenceForSame.xml [new file with mode: 0644]
src/gromacs/selection/tests/selectioncollection.cpp