Fix memory issue in solvate
[alexxy/gromacs.git] / src / tools / addconf.c
index 0df691f0b3481cdd9f89eaa037eede513909f65b..448d7955d08f2402cdf9eb217533994b34e3bf27 100644 (file)
@@ -431,6 +431,11 @@ void add_conf(t_atoms *atoms, rvec **x, rvec **v, real **r, gmx_bool bSrenew,
             for (j = j0; (j < j1 && nremove < natoms_solvt); j++)
             {
                 jnr = nlist->jjnr[j];
+                if (jnr < 0)
+                {
+                    /* skip padding */
+                    continue;
+                }
                 copy_rvec(x_all[jnr], xj);
 
                 /* Check solvent-protein and solvent-solvent */