fixed segv/hang with EM and foreign lambda values
authorBerk Hess <hess@kth.se>
Mon, 25 Jun 2012 09:39:03 +0000 (11:39 +0200)
committerBerk Hess <hess@kth.se>
Mon, 25 Jun 2012 09:39:03 +0000 (11:39 +0200)
Energy minimization with nstcalcenergy=-1, foreign lambda values
and no separate dhdl.xvg output file called malloc with negative count.
Fixes #962

Change-Id: I3d6b636ddba80fc2ae400590c48642c217325293

src/mdlib/mdebin.c

index 7e102e132e80cecdb66718c4f39cd6d1323e5386..bc073191a470bc16aee9d3ad71d7c4dba9957f85 100644 (file)
@@ -541,10 +541,13 @@ t_mdebin *init_mdebin(ener_file_t fp_ene,
     md->dhc=NULL; 
     if (ir->separate_dhdl_file == sepdhdlfileNO )
     {
-        int i;
-        snew(md->dhc, 1);
+        /* Currently dh histograms are only written with dynamics */
+        if (EI_DYNAMICS(ir->eI))
+        {
+            snew(md->dhc, 1);
 
-        mde_delta_h_coll_init(md->dhc, ir);
+            mde_delta_h_coll_init(md->dhc, ir);
+        }
         md->fp_dhdl = NULL;
     }
     else