Fix segmentation fault in do_dssp
authorPaul Bauer <paul.bauer.q@gmail.com>
Mon, 27 Apr 2020 11:46:33 +0000 (13:46 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 27 Apr 2020 13:49:02 +0000 (13:49 +0000)
A matrix would be initial allocated with zero size, so that a
following call to increase the size of one element would lead to memory
corruption on a subsequent try to set a value in the matrix.

Fixes #3444

Change-Id: I1892c09a8aa4c2f92156f7b1a76623df9ac62e56

docs/release-notes/2020/2020.2.rst
src/gromacs/gmxana/gmx_do_dssp.cpp

index 341dfd445ce1235588e4e486f4339b699e6dcc8b..ac4bed9aed658e324c5530364f18a65960108a7c 100644 (file)
@@ -54,6 +54,13 @@ When selecting a time unit of microseconds or larger,
 ``gmx tool -tu`` now produces the correct string in .xvg and
 particularly .xvgr plots
 
+Fix do_dssp
+^^^^^^^^^^^
+
+The tool would fail with a segmentation fault.
+
+:issue:`3444`
+
 Fixes that affect portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index 1935ae1c159e81c185d3564e7a7fcb42156ebe5c..d4e4edefdf5ad6d18c372e47c62c68f360b09c5b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2013,2014,2015,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -188,7 +188,7 @@ static int strip_dssp(FILE*                   tapeout,
         mat->axis_y.resize(nr);
         std::iota(mat->axis_y.begin(), mat->axis_y.end(), 1);
         mat->axis_x.resize(0);
-        mat->matrix.resize(0, 0);
+        mat->matrix.resize(1, 1);
         bFirst = false;
     }
     mat->axis_x.push_back(t);