From: David van der Spoel Date: Thu, 12 Jun 2014 07:58:11 +0000 (+0200) Subject: Fix memory-usage error in g_chi X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=820e4e531ddc59c98ed71b935e0e78724b651a9c;p=alexxy%2Fgromacs.git Fix memory-usage error in g_chi Out of array bounds writing error as pointed out by valgrind is fixed by this patch, preventing a SEGV. Fixes #1503 Change-Id: I57959f4751f3eb645ff66bbcd4418607af56c1a4 --- diff --git a/src/tools/anadih.c b/src/tools/anadih.c index 5f5da0eefb..1c0e9000dd 100644 --- a/src/tools/anadih.c +++ b/src/tools/anadih.c @@ -417,7 +417,8 @@ void mk_chi_lookup (int **lookup, int maxchi, real **dih, int i, j, Dih, Chi; j = 0; - for (Dih = 0; (Dih < NONCHI+maxchi); Dih++) + /* NONCHI points to chi1, therefore we have to start counting there. */ + for (Dih = NONCHI; (Dih < NONCHI+maxchi); Dih++) { for (i = 0; (i < nlist); i++) {